-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle when an error occurs in a beforeEach block of a mocha test. (#9)
* Handle when an error occurs in a beforeEach block of a mocha test. * fix node 4 * trigger another build * PR Feedback: Conver to use Sets * Revert "PR Feedback: Conver to use Sets" This reverts commit f8a5439. * Create correct type for failureMessagse property. * re-trigger build
- Loading branch information
Showing
8 changed files
with
76 additions
and
11 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
integrationTests/__fixtures__/errorInBeforeEach/__mocha__/__tests__/file.test.js
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,18 @@ | ||
/* eslint-disable no-unreachable */ | ||
const assert = require('assert'); | ||
|
||
describe('My tests', () => { | ||
it('This test passes', () => { | ||
assert.equal(1, 1); | ||
}); | ||
|
||
describe('Nested describe', () => { | ||
beforeEach(() => { | ||
throw new Error('Error in nested beforeEach'); | ||
}); | ||
|
||
it('This nested test passes', () => { | ||
assert.equal(1, 1); | ||
}); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
integrationTests/__fixtures__/errorInBeforeEach/jest.config.js
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,3 @@ | ||
module.exports = { | ||
runner: '../../../', | ||
}; |
17 changes: 17 additions & 0 deletions
17
integrationTests/__snapshots__/errorInBeforeEach.test.js.snap
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,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Works when it has an error inside of beforeEach 1`] = ` | ||
"FAIL integrationTests/__fixtures__/errorInBeforeEach/__mocha__/__tests__/file.test.js | ||
My tests Nested describe \\"before each\\" hook for \\"This nested test passes\\" | ||
Error: Error in nested beforeEach | ||
at mocked-stack-trace | ||
✓ This test passes | ||
✕ \\"before each\\" hook for \\"This nested test passes\\" | ||
Test Suites: 1 failed, 1 total | ||
Tests: 1 failed, 1 passed, 2 total | ||
Snapshots: 0 total | ||
Time: | ||
Ran all test suites. | ||
" | ||
`; |
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,5 @@ | ||
const runJest = require('./runJest'); | ||
|
||
it('Works when it has an error inside of beforeEach', () => { | ||
return expect(runJest('errorInBeforeEach')).resolves.toMatchSnapshot(); | ||
}); |
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
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
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
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