Use matching test command for equivalence tests (#17604)

This commit is contained in:
Dan Abramov
2019-12-14 17:52:29 +00:00
committed by GitHub
parent 8a347ed024
commit b6c423daad

View File

@@ -28,7 +28,13 @@ describe('ReactClassEquivalence', () => {
function runJest(testFile) {
const cwd = process.cwd();
const extension = process.platform === 'win32' ? '.cmd' : '';
const result = spawnSync('yarn' + extension, ['test', testFile], {
const command = process.env.npm_lifecycle_event;
if (!command.startsWith('test')) {
throw new Error(
'Expected this test to run as a result of one of test commands.',
);
}
const result = spawnSync('yarn' + extension, [command, testFile], {
cwd,
env: Object.assign({}, process.env, {
REACT_CLASS_EQUIVALENCE_TEST: 'true',