-
-
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.
Bind to Circus events via an optional event handler on any custom env. (
#8344) * Bind to Circus events via an optional event handler on any custom env. * Fix lint error. * Update CHANGELOG.md * Move Circus types into @jest/types * Move handleTestEvent definition into JestEnvironment * Fix linter errors. * Add test for Circus events being fired from environmet.
- Loading branch information
1 parent
cd415e7
commit 31e06e8
Showing
21 changed files
with
459 additions
and
339 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
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,46 @@ | ||
/** | ||
* 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 {skipSuiteOnJasmine} from '@jest/test-utils'; | ||
import runJest from '../runJest'; | ||
|
||
skipSuiteOnJasmine(); | ||
|
||
it('calls testEnvironment handleTestEvent', () => { | ||
const result = runJest('test-environment-circus'); | ||
expect(result.failed).toEqual(false); | ||
expect(result.stdout.split('\n')).toMatchInlineSnapshot(` | ||
Array [ | ||
"setup", | ||
"add_hook", | ||
"add_hook", | ||
"add_test", | ||
"add_test", | ||
"run_start", | ||
"run_describe_start", | ||
"test_start: test name here", | ||
"hook_start", | ||
"hook_success: test name here", | ||
"hook_start", | ||
"hook_success: test name here", | ||
"test_fn_start: test name here", | ||
"test_fn_success: test name here", | ||
"test_done: test name here", | ||
"test_start: second test name here", | ||
"hook_start", | ||
"hook_success: second test name here", | ||
"hook_start", | ||
"hook_success: second test name here", | ||
"test_fn_start: second test name here", | ||
"test_fn_success: second test name here", | ||
"test_done: second test name here", | ||
"run_describe_finish", | ||
"run_finish", | ||
"teardown", | ||
] | ||
`); | ||
}); |
13 changes: 13 additions & 0 deletions
13
e2e/test-environment-circus/CircusHandleTestEventEnvironment.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,13 @@ | ||
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
|
||
'use strict'; | ||
|
||
const JSDOMEnvironment = require('jest-environment-jsdom'); | ||
|
||
class TestEnvironment extends JSDOMEnvironment { | ||
handleTestEvent(event) { | ||
console.log(event.name + (event.test ? ': ' + event.test.name : '')); | ||
} | ||
} | ||
|
||
module.exports = TestEnvironment; |
15 changes: 15 additions & 0 deletions
15
e2e/test-environment-circus/__tests__/circusHandleTestEvent.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,15 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* @jest-environment ./CircusHandleTestEventEnvironment.js | ||
*/ | ||
|
||
beforeEach(() => {}); | ||
|
||
test('test name here', () => { | ||
expect(true).toBe(true); | ||
}); | ||
|
||
test('second test name here', () => { | ||
expect(true).toBe(true); | ||
}); |
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 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
} |
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
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
Oops, something went wrong.