-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: print error and exit with status 1 if logging happens after tear…
…down
- Loading branch information
Showing
7 changed files
with
133 additions
and
14 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
20 changes: 20 additions & 0 deletions
20
e2e/__tests__/__snapshots__/consoleAfterTeardown.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,20 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`console printing 1`] = ` | ||
PASS __tests__/console.test.js | ||
● Cannot log after tests are done. Did you forget to wait for something async in your test? | ||
Attempted to log "hello!". | ||
9 | test('throws error', () => { | ||
10 | setTimeout(() => { | ||
> 11 | console.log('hello!'); | ||
| ^ | ||
12 | }, 500); | ||
13 | }); | ||
14 | | ||
at Function.write (../../packages/jest-util/build/BufferedConsole.js:82:12) | ||
at Timeout.log [as _onTimeout] (__tests__/console.test.js:11:13) | ||
`; |
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,20 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
import {extractSummary} from '../Utils'; | ||
import runJest from '../runJest'; | ||
import {wrap} from 'jest-snapshot-serializer-raw'; | ||
|
||
test('console printing', () => { | ||
const {stderr, status} = runJest('console-after-teardown'); | ||
const {rest} = extractSummary(stderr); | ||
|
||
expect(status).toBe(1); | ||
expect(wrap(rest)).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
|
||
test('throws error', () => { | ||
setTimeout(() => { | ||
console.log('hello!'); | ||
}, 500); | ||
}); |
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,6 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node", | ||
"verbose": false | ||
} | ||
} |
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