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() }) }) })