-
-
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: jest-circus shares events among imports #11483
- Loading branch information
Showing
7 changed files
with
108 additions
and
6 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
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
39 changes: 39 additions & 0 deletions
39
packages/jest-circus/src/__tests__/__snapshots__/eventHandler.test.ts.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,39 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`addEventHandler registers a callback with events 1`] = ` | ||
start_describe_definition: describe | ||
add_test: receives events | ||
finish_describe_definition: describe | ||
run_start | ||
run_describe_start: ROOT_DESCRIBE_BLOCK | ||
run_describe_start: describe | ||
test_start: receives events | ||
test_fn_start: receives events | ||
called true | ||
test_fn_failure: receives events | ||
test_done: receives events | ||
run_describe_finish: describe | ||
run_describe_finish: ROOT_DESCRIBE_BLOCK | ||
run_finish | ||
unhandledErrors: 0 | ||
`; | ||
|
||
exports[`removeEventHandler unregisters a callback from events 1`] = ` | ||
start_describe_definition: describe | ||
add_test: does not receive events | ||
finish_describe_definition: describe | ||
run_start | ||
run_describe_start: ROOT_DESCRIBE_BLOCK | ||
run_describe_start: describe | ||
test_start: does not receive events | ||
test_fn_start: does not receive events | ||
called false | ||
test_fn_failure: does not receive events | ||
test_done: does not receive events | ||
run_describe_finish: describe | ||
run_describe_finish: ROOT_DESCRIBE_BLOCK | ||
run_finish | ||
unhandledErrors: 0 | ||
`; |
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,44 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
import wrap from 'jest-snapshot-serializer-raw'; | ||
import {runTest} from '../__mocks__/testUtils'; | ||
|
||
test('addEventHandler registers a callback with events', () => { | ||
const {stdout} = runTest(` | ||
let called = false; | ||
const callback = () => called = true; | ||
addEventHandler(callback); | ||
describe('describe', () => { | ||
test('receives events', () => { | ||
console.log('called', called); | ||
expect(called).toEqual(true); | ||
}) | ||
}); | ||
`); | ||
|
||
expect(wrap(stdout)).toMatchSnapshot(); | ||
}); | ||
|
||
test('removeEventHandler unregisters a callback from events', () => { | ||
const {stdout} = runTest(` | ||
let called = false; | ||
const callback = () => called = true; | ||
addEventHandler(callback); | ||
removeEventHandler(callback); | ||
describe('describe', () => { | ||
test('does not receive events', () => { | ||
console.log('called', called); | ||
expect(called).toEqual(false); | ||
}) | ||
}); | ||
`); | ||
|
||
expect(wrap(stdout)).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