-
-
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.
Setup before tests but after framework loads (#7119)
- Loading branch information
Showing
29 changed files
with
217 additions
and
85 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
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,70 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. 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 | ||
*/ | ||
'use strict'; | ||
|
||
import fs from 'fs'; | ||
import path from 'path'; | ||
import {json as runWithJson} from '../runJest'; | ||
import {writeFiles} from '../Utils'; | ||
|
||
const DIR = path.resolve(__dirname, '../setup-files-after-env-config'); | ||
|
||
const pkgJsonOutputFilePath = path.join( | ||
process.cwd(), | ||
'e2e/setup-files-after-env-config/package.json', | ||
); | ||
|
||
afterAll(() => { | ||
fs.unlinkSync(pkgJsonOutputFilePath); | ||
}); | ||
|
||
describe('setupFilesAfterEnv', () => { | ||
it('requires multiple setup files before each file in the suite', () => { | ||
const pkgJson = { | ||
jest: { | ||
setupFilesAfterEnv: ['./setup1.js', './setup2.js'], | ||
}, | ||
}; | ||
|
||
writeFiles(DIR, { | ||
'package.json': JSON.stringify(pkgJson, null, 2), | ||
}); | ||
|
||
const result = runWithJson('setup-files-after-env-config', [ | ||
'test1.test.js', | ||
'test2.test.js', | ||
]); | ||
|
||
expect(result.json.numTotalTests).toBe(2); | ||
expect(result.json.numPassedTests).toBe(2); | ||
expect(result.json.testResults.length).toBe(2); | ||
expect(result.status).toBe(0); | ||
}); | ||
|
||
it('requires setup files *after* the test runners are required', () => { | ||
const pkgJson = { | ||
jest: { | ||
setupFilesAfterEnv: ['./setup_hooks_into_runner.js'], | ||
}, | ||
}; | ||
|
||
writeFiles(DIR, { | ||
'package.json': JSON.stringify(pkgJson, null, 2), | ||
}); | ||
|
||
const result = runWithJson('setup-files-after-env-config', [ | ||
'runner_patch.test.js', | ||
]); | ||
|
||
expect(result.json.numTotalTests).toBe(1); | ||
expect(result.json.numPassedTests).toBe(1); | ||
expect(result.json.testResults.length).toBe(1); | ||
expect(result.status).toBe(0); | ||
}); | ||
}); |
40 changes: 0 additions & 40 deletions
40
e2e/__tests__/setup_test_framework_script_file_cli_config.test.js
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,8 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. 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. | ||
*/ | ||
|
||
global.definedInSetupFile = true; |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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
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.