forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for (before|after)(Each|All) methods
Summary: Add capability to setup / teardown tests Differential Revision: D68454176
- Loading branch information
1 parent
9afad52
commit b04511e
Showing
3 changed files
with
261 additions
and
46 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
61 changes: 61 additions & 0 deletions
61
packages/react-native-fantom/src/__tests__/FantomSetupHooks-itest.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,61 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
const logs: string[] = []; | ||
|
||
beforeAll(() => { | ||
logs.push('root - beforeAll'); | ||
}); | ||
|
||
afterAll(() => { | ||
logs.push('root - afterAll'); | ||
}); | ||
|
||
beforeEach(() => { | ||
logs.push('root - beforeEach'); | ||
}); | ||
|
||
afterEach(() => { | ||
logs.push('root - afterEach'); | ||
}); | ||
|
||
test('root hooks', () => { | ||
logs.push('root - test'); | ||
expect(logs).toMatchSnapshot(); | ||
}); | ||
|
||
describe('FantomSetupHooks', () => { | ||
beforeAll(() => { | ||
logs.push('FantomSetupHooks - beforeAll'); | ||
}); | ||
|
||
afterAll(() => { | ||
logs.push('FantomSetupHooks - afterAll'); | ||
}); | ||
|
||
beforeEach(() => { | ||
logs.push('FantomSetupHooks - beforeEach'); | ||
}); | ||
|
||
afterEach(() => { | ||
logs.push('FantomSetupHooks - afterEach'); | ||
}); | ||
|
||
test('first', () => { | ||
logs.push('FantomSetupHooks - first'); | ||
expect(logs).toMatchSnapshot(); | ||
}); | ||
|
||
test('second', () => { | ||
logs.push('FantomSetupHooks - second'); | ||
expect(logs).toMatchSnapshot(); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
packages/react-native-fantom/src/__tests__/__snapshots__/FantomSetupHooks-itest.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,40 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`FantomSetupHooks first 1`] = ` | ||
Array [ | ||
"root - beforeAll", | ||
"root - beforeEach", | ||
"root - test", | ||
"root - afterEach", | ||
"FantomSetupHooks - beforeAll", | ||
"root - beforeEach", | ||
"FantomSetupHooks - beforeEach", | ||
"FantomSetupHooks - first", | ||
] | ||
`; | ||
|
||
exports[`FantomSetupHooks second 1`] = ` | ||
Array [ | ||
"root - beforeAll", | ||
"root - beforeEach", | ||
"root - test", | ||
"root - afterEach", | ||
"FantomSetupHooks - beforeAll", | ||
"root - beforeEach", | ||
"FantomSetupHooks - beforeEach", | ||
"FantomSetupHooks - first", | ||
"FantomSetupHooks - afterEach", | ||
"root - afterEach", | ||
"root - beforeEach", | ||
"FantomSetupHooks - beforeEach", | ||
"FantomSetupHooks - second", | ||
] | ||
`; | ||
|
||
exports[`root hooks 1`] = ` | ||
Array [ | ||
"root - beforeAll", | ||
"root - beforeEach", | ||
"root - test", | ||
] | ||
`; |