-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: use bootstrap to start tests (#97)
- Loading branch information
Showing
2 changed files
with
13 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
}); | ||
}); |