diff --git a/unittest-jest/__tests__/controller/home.test.js b/unittest-jest/__tests__/controller/home.test.js new file mode 100644 index 00000000..18211664 --- /dev/null +++ b/unittest-jest/__tests__/controller/home.test.js @@ -0,0 +1,12 @@ +'use strict'; + +const { app } = require('egg-mock/bootstrap'); + +describe('__tests__/controller/home.test.js', () => { + it('should status 200 and get the body', () => { + return app.httpRequest() + .get('/') + .expect(200) + .expect('hello world'); + }); +}); diff --git a/unittest-jest/__tests__/index.test.js b/unittest-jest/__tests__/index.test.js index d208c3b9..5a634042 100644 --- a/unittest-jest/__tests__/index.test.js +++ b/unittest-jest/__tests__/index.test.js @@ -1,25 +1,9 @@ 'use strict'; -const mock = require('egg-mock'); +const { app } = require('egg-mock/bootstrap'); describe('__tests__/index.test.js', () => { - let app; - beforeAll(() => { - app = mock.app(); - return app.ready(); - }); - - afterEach(mock.restore); - afterAll(() => app.close()); - it('should app exist', () => { expect(app.test).toBe('123'); }); - - it('should status 200 and get the body', () => { - return app.httpRequest() - .get('/') - .expect(200) - .expect('hello world'); - }); });