Skip to content

Commit f243f6a

Browse files
committed
fix(tests): broader watch plugin options test is now correct
Refs jestjs#6693 Fixes jestjs#6473
1 parent ce52523 commit f243f6a

File tree

1 file changed

+64
-62
lines changed

1 file changed

+64
-62
lines changed

packages/jest-cli/src/__tests__/watch.test.js

Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -441,66 +441,63 @@ describe('Watch mode flows', () => {
441441
});
442442

443443
it.each`
444-
ok | option
445-
✔︎ | bail
446-
✖︎ | changedFilesWithAncestor
447-
✖︎ | changedSince
448-
✔︎ | collectCoverage
449-
✔︎ | collectCoverageFrom
450-
✔︎ | collectCoverageOnlyFrom
451-
✔︎ | coverageDirectory
452-
✔︎ | coverageReporters
453-
✖︎ | coverageThreshold
454-
✖︎ | detectLeaks
455-
✖︎ | detectOpenHandles
456-
✖︎ | enabledTestsMap
457-
✖︎ | errorOnDeprecated
458-
✖︎ | expand
459-
✖︎ | filter
460-
✖︎ | findRelatedTests
461-
✖︎ | forceExit
462-
✖︎ | globalSetup
463-
✖︎ | globalTeardown
464-
✖︎ | json
465-
✖︎ | lastCommit
466-
✖︎ | listTests
467-
✖︎ | logHeapUsage
468-
✖︎ | maxWorkers
469-
✖︎ | nonFlagArgs
470-
✖︎ | noSCM
471-
✖︎ | noStackTrace
472-
✔︎ | notify
473-
✔︎ | notifyMode
474-
✖︎ | onlyChanged
475-
✔︎ | onlyFailures
476-
✖︎ | outputFile
477-
✖︎ | passWithNoTests
478-
✖︎ | projects
479-
✖︎ | replname
480-
✔︎ | reporters
481-
✖︎ | rootDir
482-
✖︎ | runTestsByPath
483-
✖︎ | silent
484-
✖︎ | skipFilter
485-
✖︎ | testFailureExitCode
486-
✔︎ | testNamePattern
487-
✔︎ | testPathPattern
488-
✖︎ | testResultsProcessor
489-
✔︎ | updateSnapshot
490-
✖︎ | useStderr
491-
✔︎ | verbose
492-
✖︎ | watch
493-
✖︎ | watchAll
494-
✖︎ | watchman
495-
✖︎ | watchPlugins
444+
ok | option
445+
${'✔︎'} | ${'bail'}
446+
${'✖︎'} | ${'changedFilesWithAncestor'}
447+
${'✖︎'} | ${'changedSince'}
448+
${'✔︎'} | ${'collectCoverage'}
449+
${'✔︎'} | ${'collectCoverageFrom'}
450+
${'✔︎'} | ${'collectCoverageOnlyFrom'}
451+
${'✔︎'} | ${'coverageDirectory'}
452+
${'✔︎'} | ${'coverageReporters'}
453+
${'✖︎'} | ${'coverageThreshold'}
454+
${'✖︎'} | ${'detectLeaks'}
455+
${'✖︎'} | ${'detectOpenHandles'}
456+
${'✖︎'} | ${'enabledTestsMap'}
457+
${'✖︎'} | ${'errorOnDeprecated'}
458+
${'✖︎'} | ${'expand'}
459+
${'✖︎'} | ${'filter'}
460+
${'✖︎'} | ${'findRelatedTests'}
461+
${'✖︎'} | ${'forceExit'}
462+
${'✖︎'} | ${'globalSetup'}
463+
${'✖︎'} | ${'globalTeardown'}
464+
${'✖︎'} | ${'json'}
465+
${'✖︎'} | ${'lastCommit'}
466+
${'✖︎'} | ${'listTests'}
467+
${'✖︎'} | ${'logHeapUsage'}
468+
${'✖︎'} | ${'maxWorkers'}
469+
${'✖︎'} | ${'nonFlagArgs'}
470+
${'✖︎'} | ${'noSCM'}
471+
${'✖︎'} | ${'noStackTrace'}
472+
${'✔︎'} | ${'notify'}
473+
${'✔︎'} | ${'notifyMode'}
474+
${'✖︎'} | ${'onlyChanged'}
475+
${'✔︎'} | ${'onlyFailures'}
476+
${'✖︎'} | ${'outputFile'}
477+
${'✖︎'} | ${'passWithNoTests'}
478+
${'✖︎'} | ${'projects'}
479+
${'✖︎'} | ${'replname'}
480+
${'✔︎'} | ${'reporters'}
481+
${'✖︎'} | ${'rootDir'}
482+
${'✖︎'} | ${'runTestsByPath'}
483+
${'✖︎'} | ${'silent'}
484+
${'✖︎'} | ${'skipFilter'}
485+
${'✖︎'} | ${'testFailureExitCode'}
486+
${'✔︎'} | ${'testNamePattern'}
487+
${'✔︎'} | ${'testPathPattern'}
488+
${'✖︎'} | ${'testResultsProcessor'}
489+
${'✔︎'} | ${'updateSnapshot'}
490+
${'✖︎'} | ${'useStderr'}
491+
${'✔︎'} | ${'verbose'}
492+
${'✖︎'} | ${'watch'}
493+
${'✖︎'} | ${'watchAll'}
494+
${'✖︎'} | ${'watchman'}
495+
${'✖︎'} | ${'watchPlugins'}
496496
`(
497497
'allows WatchPlugins to modify only white-listed global config keys',
498498
async ({ok, option}) => {
499-
const pluginPath = `${__dirname}/__fixtures__/plugin_path_config_updater`;
500-
const config = Object.assign({}, globalConfig, {
501-
rootDir: __dirname,
502-
watchPlugins: [{config: {}, path: pluginPath}],
503-
});
499+
ok = ok === '✔︎';
500+
const pluginPath = `${__dirname}/__fixtures__/plugin_path_config_updater_${option}`;
504501

505502
jest.doMock(
506503
pluginPath,
@@ -518,20 +515,25 @@ describe('Watch mode flows', () => {
518515
{virtual: true},
519516
);
520517

518+
const config = Object.assign({}, globalConfig, {
519+
rootDir: __dirname,
520+
watchPlugins: [{config: {}, path: pluginPath}],
521+
});
522+
521523
watch(config, contexts, pipe, hasteMapInstances, stdin);
522524
await nextTick();
523525

524526
stdin.emit('x');
525527
await nextTick();
526528

527-
const lastCall = updateGlobalConfig.mock.calls.slice(-1)[0];
528-
let expector = expect(lastCall[0]);
529+
// We need the penultimate call as Jest forces a final call to restore
530+
// updateSnapshot because it's not sticky after a run…?
531+
const lastCall = updateGlobalConfig.mock.calls.slice(-2)[0];
532+
let expector = expect(lastCall[1]);
529533
if (!ok) {
530534
expector = expector.not;
531535
}
532-
expector.toMatchObject({
533-
[option]: '__JUST_TRYING__',
534-
});
536+
expector.toHaveProperty(option, '__JUST_TRYING__');
535537
},
536538
);
537539

0 commit comments

Comments
 (0)