Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make testNamePattern and testPathPattern play better together #3327

Merged
merged 7 commits into from
Apr 27, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
7 changes: 5 additions & 2 deletions packages/jest-cli/src/TestNamePatternPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const formatTestNameByPattern = require('./lib/formatTestNameByPattern');
const pluralizeTest = (total: number) => (total === 1 ? 'test' : 'tests');

const usage = () =>
`\n ${chalk.bold('Pattern Mode Usage')}\n` +
`\n${chalk.bold('Pattern Mode Usage')}\n` +
` ${chalk.dim('\u203A Press')} Esc ${chalk.dim('to exit pattern mode.')}\n` +
` ${chalk.dim('\u203A Press')} Enter ` +
`${chalk.dim('to apply pattern to all tests.')}\n` +
Expand All @@ -40,9 +40,12 @@ module.exports = class TestNamePatternPrompt {
this._prompt = prompt;
}

run(onSuccess: Function, onCancel: Function) {
run(onSuccess: Function, onCancel: Function, options) {
Copy link
Member

Choose a reason for hiding this comment

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

this needs types :)

this._pipe.write(ansiEscapes.cursorHide);
this._pipe.write(ansiEscapes.clearScreen);
if (options && options.header) {
this._pipe.write(options.header);
}
this._pipe.write(usage());
this._pipe.write(ansiEscapes.cursorShow);

Expand Down
7 changes: 5 additions & 2 deletions packages/jest-cli/src/TestPathPatternPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type SearchSources = Array<{|
const pluralizeFile = (total: number) => (total === 1 ? 'file' : 'files');

const usage = () =>
`\n ${chalk.bold('Pattern Mode Usage')}\n` +
`\n${chalk.bold('Pattern Mode Usage')}\n` +
` ${chalk.dim('\u203A Press')} Esc ${chalk.dim('to exit pattern mode.')}\n` +
` ${chalk.dim('\u203A Press')} Enter ` +
`${chalk.dim('to apply pattern to all filenames.')}\n` +
Expand All @@ -48,9 +48,12 @@ module.exports = class TestPathPatternPrompt {
this._prompt = prompt;
}

run(onSuccess: Function, onCancel: Function) {
run(onSuccess: Function, onCancel: Function, options) {
this._pipe.write(ansiEscapes.cursorHide);
this._pipe.write(ansiEscapes.clearScreen);
if (options && options.header) {
this._pipe.write(options.header);
}
this._pipe.write(usage());
this._pipe.write(ansiEscapes.cursorShow);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,30 @@ exports[`Watch mode flows Pressing "P" enters pattern mode 8`] = `
[MOCK - cursorRestorePosition]"
`;

exports[`Watch mode flows Pressing "c" clears the filters 1`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]



Pattern Mode Usage
› Press Esc to exit pattern mode.
› Press Enter to apply pattern to all filenames.


[MOCK - cursorShow]



pattern ›
[MOCK - cursorSavePosition]


Start typing to filter by a filename regex pattern.
[MOCK - cursorTo(11, 5)]
[MOCK - cursorRestorePosition]"
`;

exports[`Watch mode flows Results in pattern mode get truncated appropriately 1`] = `
"

Expand Down Expand Up @@ -312,3 +336,128 @@ exports[`Watch mode flows Results in pattern mode get truncated appropriately 3`
[MOCK - cursorTo(12, 5)]
[MOCK - cursorRestorePosition]"
`;

exports[`Watch mode flows Shows the appropiate header when both filters are active 1`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]

Active Filters: filename /p.*10/, test name /test/


Pattern Mode Usage
› Press Esc to exit pattern mode.
› Press Enter to apply pattern to all tests.


[MOCK - cursorShow]



pattern ›
[MOCK - cursorSavePosition]


Start typing to filter by a test name regex pattern.
[MOCK - cursorTo(11, 5)]
[MOCK - cursorRestorePosition]"
`;

exports[`Watch mode flows Shows the appropiate header when the filename filter is active 1`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]

Active Filters: filename /p.*10/


Pattern Mode Usage
› Press Esc to exit pattern mode.
› Press Enter to apply pattern to all filenames.


[MOCK - cursorShow]



pattern ›
[MOCK - cursorSavePosition]


Start typing to filter by a filename regex pattern.
[MOCK - cursorTo(11, 5)]
[MOCK - cursorRestorePosition]"
`;

exports[`Watch mode flows Shows the appropiate header when the filename filter is active 2`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]

Active Filters: filename /p/


Pattern Mode Usage
› Press Esc to exit pattern mode.
› Press Enter to apply pattern to all filenames.


[MOCK - cursorShow]



pattern ›
[MOCK - cursorSavePosition]


Start typing to filter by a filename regex pattern.
[MOCK - cursorTo(11, 5)]
[MOCK - cursorRestorePosition]"
`;

exports[`Watch mode flows Shows the appropiate header when the test name filter is active 1`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]

Active Filters: test name /test/


Pattern Mode Usage
› Press Esc to exit pattern mode.
› Press Enter to apply pattern to all tests.


[MOCK - cursorShow]



pattern ›
[MOCK - cursorSavePosition]


Start typing to filter by a test name regex pattern.
[MOCK - cursorTo(11, 5)]
[MOCK - cursorRestorePosition]"
`;

exports[`Watch mode flows Shows the appropiate header when the test name filter is active 2`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]

Active Filters: test name /t/


Pattern Mode Usage
› Press Esc to exit pattern mode.
› Press Enter to apply pattern to all tests.


[MOCK - cursorShow]



pattern ›
[MOCK - cursorSavePosition]


Start typing to filter by a test name regex pattern.
[MOCK - cursorTo(11, 5)]
[MOCK - cursorRestorePosition]"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Array [
Watch Usage
› Press o to only run tests related to changed files.
› Press p to filter by a filename regex pattern.
› Press t to filter by a test name regex pattern.
› Press q to quit watch mode.
› Press Enter to trigger a test run.
",
Expand Down
Loading