Skip to content

Commit

Permalink
Add typeahead to watch mode (#2324)
Browse files Browse the repository at this point in the history
* Extract typeahead printing logic

* Handle escape when in typeahead

* Add tests and highlight

* Update Flow and fix flow errors.

* Improve printing of test paths.

* Polish

* Fix node 4 CI

* Reset pattern state if FS changes

* Only instantiate searchSource once

* Clear screen when entering typeahead

* Show "pattern mode" and clear screen
  • Loading branch information
rogeliog authored and cpojer committed Jan 13, 2017
1 parent 88a543a commit fddd6d3
Show file tree
Hide file tree
Showing 13 changed files with 565 additions and 46 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"eslint-plugin-flow-vars": "^0.5.0",
"eslint-plugin-flowtype": "^2.28.2",
"eslint-plugin-react": "^6.7.1",
"flow-bin": "^0.37.0",
"flow-bin": "^0.37.4",
"glob": "^7.1.1",
"graceful-fs": "^4.1.11",
"istanbul-api": "^1.1.0",
Expand Down
9 changes: 5 additions & 4 deletions packages/jest-cli/src/SearchSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

'use strict';

import type {Config} from 'types/Config';
import type {HasteContext} from 'types/HasteMap';
import type {Path} from 'types/Config';
import type {ResolveModuleConfig} from 'jest-resolve';
Expand All @@ -25,11 +26,11 @@ const {
replacePathSepForRegex,
} = require('jest-util');

type SearchSourceConfig = {|
type SearchSourceConfig = {
testPathDirs: Array<Path>,
testRegex: string,
testPathIgnorePatterns: Array<RegExp>,
|};
testPathIgnorePatterns: Array<string>,
};

type SearchResult = {|
noSCM?: boolean,
Expand Down Expand Up @@ -218,7 +219,7 @@ class SearchSource {

getNoTestsFoundMessage(
patternInfo: PatternInfo,
config: {[key: string]: string},
config: Config,
data: SearchResult,
): string {
if (patternInfo.onlyChanged) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
exports[`Watch mode flows Pressing "P" enters pattern mode 1`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]
Pattern Mode Usage
› Press ESC to exit pattern mode.
pattern › p
[MOCK - cursorSavePosition]
Pattern matches 11 files.
› path/to/file1-test.js
› path/to/file2-test.js
› path/to/file3-test.js
› path/to/file4-test.js
› path/to/file5-test.js
› path/to/file6-test.js
› path/to/file7-test.js
› path/to/file8-test.js
› path/to/file9-test.js
› path/to/file10-test.js
› and 1 more file
[MOCK - cursorRestorePosition]
[MOCK - cursorShow]"
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 2`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]
Pattern Mode Usage
› Press ESC to exit pattern mode.
pattern › p.
[MOCK - cursorSavePosition]
Pattern matches 11 files.
› path/to/file1-test.js
› path/to/file2-test.js
› path/to/file3-test.js
› path/to/file4-test.js
› path/to/file5-test.js
› path/to/file6-test.js
› path/to/file7-test.js
› path/to/file8-test.js
› path/to/file9-test.js
› path/to/file10-test.js
› and 1 more file
[MOCK - cursorRestorePosition]
[MOCK - cursorShow]"
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 3`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]
Pattern Mode Usage
› Press ESC to exit pattern mode.
pattern › p.*
[MOCK - cursorSavePosition]
Pattern matches 11 files.
› path/to/file1-test.js
› path/to/file2-test.js
› path/to/file3-test.js
› path/to/file4-test.js
› path/to/file5-test.js
› path/to/file6-test.js
› path/to/file7-test.js
› path/to/file8-test.js
› path/to/file9-test.js
› path/to/file10-test.js
› and 1 more file
[MOCK - cursorRestorePosition]
[MOCK - cursorShow]"
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 4`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]
Pattern Mode Usage
› Press ESC to exit pattern mode.
pattern › p.*1
[MOCK - cursorSavePosition]
Pattern matches 3 files.
› path/to/file1-test.js
› path/to/file10-test.js
› path/to/file11-test.js
[MOCK - cursorRestorePosition]
[MOCK - cursorShow]"
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 5`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]
Pattern Mode Usage
› Press ESC to exit pattern mode.
pattern › p.*10
[MOCK - cursorSavePosition]
Pattern matches 1 file.
› path/to/file10-test.js
[MOCK - cursorRestorePosition]
[MOCK - cursorShow]"
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 6`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]
Pattern Mode Usage
› Press ESC to exit pattern mode.
pattern › p.*1
[MOCK - cursorSavePosition]
Pattern matches 3 files.
› path/to/file1-test.js
› path/to/file10-test.js
› path/to/file11-test.js
[MOCK - cursorRestorePosition]
[MOCK - cursorShow]"
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 7`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]
Pattern Mode Usage
› Press ESC to exit pattern mode.
pattern › p.*
[MOCK - cursorSavePosition]
Pattern matches 11 files.
› path/to/file1-test.js
› path/to/file2-test.js
› path/to/file3-test.js
› path/to/file4-test.js
› path/to/file5-test.js
› path/to/file6-test.js
› path/to/file7-test.js
› path/to/file8-test.js
› path/to/file9-test.js
› path/to/file10-test.js
› and 1 more file
[MOCK - cursorRestorePosition]
[MOCK - cursorShow]"
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 8`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]
Pattern Mode Usage
› Press ESC to exit pattern mode.
pattern › p.*3
[MOCK - cursorSavePosition]
Pattern matches 1 file.
› path/to/file3-test.js
[MOCK - cursorRestorePosition]
[MOCK - cursorShow]"
`;

0 comments on commit fddd6d3

Please sign in to comment.