-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add tests * Setup travis * Fix tests * Update test name
- Loading branch information
Showing
11 changed files
with
1,237 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- 8 | ||
- node | ||
- 6 | ||
script: | ||
- yarn lint | ||
- yarn test --coverage | ||
cache: | ||
yarn: true | ||
branches: | ||
only: | ||
- master | ||
# Practical when batching releases | ||
- next | ||
- "/^greenkeeper/.*$/" | ||
- "8" | ||
- "6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/__tests__/__snapshots__/file_name_pattern_prompt.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`can select a pattern that matches multiple files 1`] = ` | ||
pattern › f | ||
[MOCK - cursorSavePosition] | ||
Pattern matches 3 files | ||
› src/foo.js | ||
› src/file-1.js | ||
› src/file-2.js | ||
[MOCK - cursorTo(12, 5)] | ||
[MOCK - cursorRestorePosition] | ||
pattern › fi | ||
[MOCK - cursorSavePosition] | ||
Pattern matches 2 files | ||
› src/file-1.js | ||
› src/file-2.js | ||
[MOCK - cursorTo(13, 5)] | ||
[MOCK - cursorRestorePosition] | ||
`; | ||
|
||
exports[`can use arrows to select a specific file 1`] = ` | ||
pattern › f | ||
[MOCK - cursorSavePosition] | ||
Pattern matches 3 files | ||
› src/foo.js | ||
› src/file-1.js | ||
› src/file-2.js | ||
[MOCK - cursorTo(12, 5)] | ||
[MOCK - cursorRestorePosition] | ||
pattern › fi | ||
[MOCK - cursorSavePosition] | ||
Pattern matches 2 files | ||
› src/file-1.js | ||
› src/file-2.js | ||
[MOCK - cursorTo(13, 5)] | ||
[MOCK - cursorRestorePosition] | ||
pattern › fi | ||
[MOCK - cursorSavePosition] | ||
Pattern matches 2 files | ||
› src/file-1.js | ||
› src/file-2.js | ||
[MOCK - cursorTo(13, 5)] | ||
[MOCK - cursorRestorePosition] | ||
`; | ||
|
||
exports[`shows the correct initial state 1`] = ` | ||
[MOCK - cursorHide] | ||
[MOCK - clearScreen] | ||
Pattern Mode Usage | ||
› Press Esc to exit pattern mode. | ||
› Press Enter to filter by a filenames regex pattern. | ||
[MOCK - cursorShow] | ||
pattern › | ||
[MOCK - cursorSavePosition] | ||
Start typing to filter by a filename regex pattern. | ||
[MOCK - cursorTo(11, 5)] | ||
[MOCK - cursorRestorePosition] | ||
`; |
121 changes: 121 additions & 0 deletions
121
src/__tests__/__snapshots__/test_name_pattern_prompt.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`can select a pattern that matches multiple tests 1`] = ` | ||
pattern › f | ||
[MOCK - cursorSavePosition] | ||
Pattern matches 2 tests from cached test suites | ||
› foo 1 | ||
› foo 2 | ||
[MOCK - cursorTo(12, 5)] | ||
[MOCK - cursorRestorePosition] | ||
pattern › fo | ||
[MOCK - cursorSavePosition] | ||
Pattern matches 2 tests from cached test suites | ||
› foo 1 | ||
› foo 2 | ||
[MOCK - cursorTo(13, 5)] | ||
[MOCK - cursorRestorePosition] | ||
`; | ||
|
||
exports[`can use arrows to select a specific test 1`] = ` | ||
pattern › f | ||
[MOCK - cursorSavePosition] | ||
Pattern matches 2 tests from cached test suites | ||
› foo 1 | ||
› foo 2 | ||
[MOCK - cursorTo(12, 5)] | ||
[MOCK - cursorRestorePosition] | ||
pattern › f | ||
[MOCK - cursorSavePosition] | ||
Pattern matches 2 tests from cached test suites | ||
› foo 1 | ||
› foo 2 | ||
[MOCK - cursorTo(12, 5)] | ||
[MOCK - cursorRestorePosition] | ||
pattern › f | ||
[MOCK - cursorSavePosition] | ||
Pattern matches 2 tests from cached test suites | ||
› foo 1 | ||
› foo 2 | ||
[MOCK - cursorTo(12, 5)] | ||
[MOCK - cursorRestorePosition] | ||
`; | ||
|
||
exports[`shows the correct initial state 1`] = ` | ||
[MOCK - cursorHide] | ||
[MOCK - clearScreen] | ||
Pattern Mode Usage | ||
› Press Esc to exit pattern mode. | ||
› Press Enter to filter by a tests regex pattern. | ||
[MOCK - cursorShow] | ||
pattern › | ||
[MOCK - cursorSavePosition] | ||
Start typing to filter by a test name regex pattern. | ||
[MOCK - cursorTo(11, 5)] | ||
[MOCK - cursorRestorePosition] | ||
`; | ||
|
||
exports[`shows the correct message when there are no cached tests 1`] = ` | ||
[MOCK - cursorHide] | ||
[MOCK - clearScreen] | ||
Pattern Mode Usage | ||
› Press Esc to exit pattern mode. | ||
› Press Enter to filter by a tests regex pattern. | ||
[MOCK - cursorShow] | ||
pattern › | ||
[MOCK - cursorSavePosition] | ||
Start typing to filter by a test name regex pattern. | ||
[MOCK - cursorTo(11, 5)] | ||
[MOCK - cursorRestorePosition] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { KEYS } from 'jest-watcher'; | ||
import pluginTester from './pluginTester'; | ||
import FileNamePlugin from '../file_name_plugin'; | ||
|
||
const projects = [ | ||
{ | ||
config: { | ||
rootDir: '/project', | ||
}, | ||
testPaths: ['/project/src/foo.js', '/project/src/file-1.js'], | ||
}, | ||
{ | ||
config: { | ||
rootDir: '/project', | ||
}, | ||
testPaths: ['/project/src/bar.js', '/project/src/file-2.js'], | ||
}, | ||
]; | ||
|
||
it('shows the correct initial state', async () => { | ||
const { | ||
stdout, | ||
hookEmitter, | ||
updateConfigAndRun, | ||
plugin, | ||
type, | ||
} = pluginTester(FileNamePlugin); | ||
|
||
hookEmitter.onFileChange({ projects }); | ||
const runPromise = plugin.run({}, updateConfigAndRun); | ||
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot(); | ||
type(KEYS.ENTER); | ||
|
||
await runPromise; | ||
}); | ||
|
||
it('can use arrows to select a specific file', async () => { | ||
const { | ||
stdout, | ||
hookEmitter, | ||
updateConfigAndRun, | ||
plugin, | ||
type, | ||
} = pluginTester(FileNamePlugin); | ||
|
||
hookEmitter.onFileChange({ projects }); | ||
const runPromise = plugin.run({}, updateConfigAndRun); | ||
stdout.write.mockReset(); | ||
type('f', 'i', KEYS.ARROW_DOWN, KEYS.ENTER); | ||
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot(); | ||
|
||
await runPromise; | ||
|
||
expect(updateConfigAndRun).toHaveBeenCalledWith({ | ||
mode: 'watch', | ||
testPathPattern: 'src/file-1.js', | ||
}); | ||
}); | ||
|
||
it('can select a pattern that matches multiple files', async () => { | ||
const { | ||
stdout, | ||
hookEmitter, | ||
updateConfigAndRun, | ||
plugin, | ||
type, | ||
} = pluginTester(FileNamePlugin); | ||
|
||
hookEmitter.onFileChange({ projects }); | ||
const runPromise = plugin.run({}, updateConfigAndRun); | ||
stdout.write.mockReset(); | ||
type('f', 'i', KEYS.ENTER); | ||
expect(stdout.write.mock.calls.join('\n')).toMatchSnapshot(); | ||
|
||
await runPromise; | ||
|
||
expect(updateConfigAndRun).toHaveBeenCalledWith({ | ||
mode: 'watch', | ||
testPathPattern: 'fi', | ||
}); | ||
}); |
Oops, something went wrong.