Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
396cd18
Start adding tapable
rogeliog Jan 17, 2018
c04edc7
Use test_path_pattern as a plugin
rogeliog Jan 19, 2018
1f74aa1
Use test_name_pattern as a plugin
rogeliog Jan 19, 2018
03b53b1
Use quit as a plugin
rogeliog Jan 19, 2018
1aeafb8
Fix test interruption
rogeliog Jan 19, 2018
b40f604
Use update snapshot as a plugin
rogeliog Jan 19, 2018
6e97a6e
Use update snapshot interactive as a plugin
rogeliog Jan 25, 2018
ef14ade
Change API to use a class instance
rogeliog Jan 26, 2018
8b999ed
Merge branch 'master' into simpler-plugins
rogeliog Jan 26, 2018
2604965
A bit of clean up and make tests pass
rogeliog Jan 26, 2018
ffc85f1
Change plugin implementation to not use tapable
rogeliog Feb 2, 2018
053d9e4
Better sorting implementation
rogeliog Feb 2, 2018
2036be9
Add back third party plugin functionality
rogeliog Feb 2, 2018
40c4265
Fix flow
rogeliog Feb 2, 2018
44c82ba
Merge branch 'master' into simpler-plugins
rogeliog Feb 2, 2018
7767b71
Fix ESLint
rogeliog Feb 2, 2018
2b084f8
Reset file to state of master
rogeliog Feb 2, 2018
58f1717
Update failing snapshot
rogeliog Feb 2, 2018
13f08e5
Merge branch 'master' into simpler-plugins
rogeliog Feb 6, 2018
d4ecb92
Remove hasSnapshotFailure and hasSnapshotFailureInteractive
rogeliog Feb 6, 2018
8f6513e
Async await for showPrompt and clear active plugin on file change
rogeliog Feb 6, 2018
401e44b
Fix snapshot failure
rogeliog Feb 6, 2018
9ac7d94
Reenable tests
rogeliog Feb 6, 2018
25e0c4b
Implement shouldRunTestSuite
rogeliog Feb 6, 2018
4a68617
Add changelog
rogeliog Feb 6, 2018
3dc8c06
Clean up watch.js a bit
rogeliog Feb 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use quit as a plugin
  • Loading branch information
rogeliog committed Jan 19, 2018
commit 03b53b125a7d8c56941d126628a33c3086ac4fb9
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Watch Usage
› Press a to run all tests.
› Press f to run only failed tests.
› Press p to filter by a filename regex pattern.
› Press t to filter by a test regex pattern.
› Press q to quit watch mode.
› Press t to filter by a test regex pattern.
› Press Enter to trigger a test run.
",
]
Expand All @@ -29,10 +29,10 @@ Watch Usage
› Press a to run all tests.
› Press f to run only failed tests.
› Press p to filter by a filename regex pattern.
› Press q to quit watch mode.
› Press s to do nothing.
› Press t to filter by a test regex pattern.
› Press u to do something else.
› Press q to quit watch mode.
› Press Enter to trigger a test run.
",
],
Expand Down
1 change: 0 additions & 1 deletion packages/jest-cli/src/lib/watch_plugin_registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import getType from 'jest-get-type';

const RESERVED_KEYS = [
0x03, // Jest should handle ctrl-c interrupt
'q'.codePointAt(0), // 'q' is reserved for quit
];

export default class WatchPluginRegistry {
Expand Down
24 changes: 24 additions & 0 deletions packages/jest-cli/src/plugins/quit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* 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
*/
import type {WatchPlugin} from '../types';

const PLUGIN_NAME = 'quit';
const testPathPatternPlugin: WatchPlugin = {
apply: (jestHooks, {stdin, stdout}) => {
jestHooks.showPrompt.tapPromise(PLUGIN_NAME, () => {
stdout.write('\n');
process.exit(0);
});
},
key: 'q'.codePointAt(0),
name: PLUGIN_NAME,
prompt: 'quit watch mode',
};

export default testPathPatternPlugin;
17 changes: 9 additions & 8 deletions packages/jest-cli/src/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ import {AsyncSeriesWaterfallHook} from 'tapable';

let hasExitListener = false;

const internalPlugins = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will get cleaned up

require.resolve('./plugins/test_path_pattern'),
require.resolve('./plugins/test_name_pattern'),
require.resolve('./plugins/quit'),
];

export default function watch(
initialGlobalConfig: GlobalConfig,
contexts: Array<Context>,
Expand Down Expand Up @@ -71,8 +77,9 @@ export default function watch(

const watchPlugins = new WatchPluginRegistry(globalConfig.rootDir);

watchPlugins.loadPluginPath(require.resolve('./plugins/test_path_pattern'));
watchPlugins.loadPluginPath(require.resolve('./plugins/test_name_pattern'));
internalPlugins.forEach(pluginPath => {
watchPlugins.loadPluginPath(pluginPath);
});

if (globalConfig.watchPlugins != null) {
for (const pluginModulePath of globalConfig.watchPlugins) {
Expand Down Expand Up @@ -253,10 +260,6 @@ export default function watch(
}

switch (key) {
case KEYS.Q:
outputStream.write('\n');
exit(0);
return;
case KEYS.ENTER:
startRun(globalConfig);
break;
Expand Down Expand Up @@ -434,8 +437,6 @@ const usage = (
chalk.dim(`to ${plugin.prompt}.`),
),

chalk.dim(' \u203A Press ') + 'q' + chalk.dim(' to quit watch mode.'),

chalk.dim(' \u203A Press ') +
'Enter' +
chalk.dim(' to trigger a test run.'),
Expand Down