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

Setup Travis and add tests #12

Merged
merged 4 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 2 additions & 14 deletions .travis.yml
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"
28 changes: 17 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,21 @@
"url": "https://github.com/jest-community/jest-watch-typeahead.git"
},
"homepage": "https://github.com/jest-community/jest-watch-typeahead",
"files": [
"build/",
"filename.js",
"testname.js"
],
"files": ["build/", "filename.js", "testname.js"],
"scripts": {
"test": "jest",
"lint": "eslint .",
"watch": "babel src -w --ignore **/*.test.js,integration -d build",
"build": "babel src --ignore **/*.test.js,integration -d build",
"prepublish": "yarn build",
"format": "prettier --single-quote --trailing-comma all --write \"!(build)/**/*.js\""
"format":
"prettier --single-quote --trailing-comma all --write \"!(build)/**/*.js\""
},
"dependencies": {
"chalk": "^2.3.1",
"chalk": "^2.4.1",
"jest-watcher": "^23.1.0",
"slash": "^1.0.0",
"string-length": "^2.0.0",
"strip-ansi": "^4.0.0"
"string-length": "^2.0.0"
},
"devDependencies": {
"babel-cli": "6.26.0",
Expand All @@ -43,7 +39,17 @@
"eslint-plugin-jest": "21.12.2",
"eslint-plugin-prettier": "2.6.0",
"flow-bin": "^0.66.0",
"jest": "22.4.2",
"prettier": "1.11.1"
"jest": "23.2.0",
"prettier": "1.11.1",
"strip-ansi": "^4.0.0"
},
"jest": {
"snapshotSerializers": [
"<rootDir>/node_modules/pretty-format/build/plugins/convert_ansi"
],
"testPathIgnorePatterns": [
"<rootDir>/build/.*",
"<rootDir>/src/__tests__/pluginTester.js"
]
}
}
103 changes: 103 additions & 0 deletions src/__tests__/__snapshots__/file_name_pattern_prompt.test.js.snap
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 src/__tests__/__snapshots__/test_name_pattern_prompt.test.js.snap
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]
`;
81 changes: 81 additions & 0 deletions src/__tests__/file_name_pattern_prompt.test.js
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',
});
});
Loading