Created
September 20, 2019 08:05
-
-
Save rynkis/226023c99a170b5828821d69208b3cbe to your computer and use it in GitHub Desktop.
api testing sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const should = require('should') | |
const request = require('supertest') | |
const app = require('/path/to/app').default.app | |
const { describe, it } = global | |
const username = 'username' | |
const password = 'password' | |
describe('token api test', () => { | |
describe('get token: login', () => { | |
it('should without error', async () => { | |
const res = await request(app).post(`/token`) | |
.set('Accept', 'application/json') | |
.send({ username, password }) | |
.expect(200) | |
.expect('Content-Type', /json/) | |
should(res.body.code).be.equal(0) | |
should(res.body.data).be.a.Object() | |
should(res.body.data.token).be.a.String() | |
should(res.body.data.refresh_token).be.a.String() | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment