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

feat: bump jest 24; add todo helper #14

Merged
merged 4 commits into from
Feb 2, 2019
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
2 changes: 2 additions & 0 deletions integrationTests/__fixtures__/todo/__src__/file1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 📃
console.log();
4 changes: 4 additions & 0 deletions integrationTests/__fixtures__/todo/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
runner: require.resolve('../../runner'),
testMatch: ['**/__src__/**/*.js'],
};
12 changes: 12 additions & 0 deletions integrationTests/__snapshots__/todo.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Works when it has todo tests 1`] = `
"PASS integrationTests/__fixtures__/todo/__src__/file1.js
Test Suites: 1 passed, 1 total
Tests: 1 todo, 1 total
Snapshots: 0 total
Time:
Ran all test suites.
"
`;
5 changes: 2 additions & 3 deletions integrationTests/runJest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const execa = require('execa');
const execa = require('execa'); // eslint-disable-line import/no-extraneous-dependencies
const path = require('path');

const rootDir = path.resolve(__dirname, '..');
Expand All @@ -16,7 +15,7 @@ const normalize = output =>

const runJest = (project, options = []) => {
// eslint-disable-next-line
jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000;
jest.setTimeout(15000);
return execa(
'jest',
[
Expand Down
5 changes: 4 additions & 1 deletion integrationTests/runner/run.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs');
const { pass, fail, skip } = require('../../');
const { pass, fail, skip, todo } = require('../../');

module.exports = ({ testPath }) => {
const start = Date.now();
Expand All @@ -12,6 +12,9 @@ module.exports = ({ testPath }) => {
if (contents.includes('🙈')) {
return skip({ start, end, test: { path: testPath } });
}
if (contents.includes('📃')) {
return todo({ start, end, test: { path: testPath } });
}
const errorMessage = 'Company policies require ⚔️ 🏃 in every file';
return fail({
start,
Expand Down
5 changes: 5 additions & 0 deletions integrationTests/todo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const runJest = require('./runJest');

it('Works when it has todo tests', () => {
return expect(runJest('todo')).resolves.toMatchSnapshot();
});
1 change: 1 addition & 0 deletions lib/fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const fail = ({ start, end, test, errorMessage }) =>
failures: 1,
pending: 0,
passes: 0,
todo: 0,
start,
end,
},
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { default as createJestRunner } from './createJestRunner';
export { default as fail } from './fail';
export { default as pass } from './pass';
export { default as skip } from './skip';
export { default as todo } from './todo';
1 change: 1 addition & 0 deletions lib/pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const pass = ({ start, end, test }) =>
failures: 0,
pending: 0,
passes: 1,
todo: 0,
start,
end,
},
Expand Down
1 change: 1 addition & 0 deletions lib/skip.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const skip = ({ start, end, test }) =>
failures: 0,
pending: 1,
passes: 0,
todo: 0,
start,
end,
},
Expand Down
1 change: 1 addition & 0 deletions lib/toTestResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const toTestResult = ({
numFailingTests: stats.failures,
numPassingTests: stats.passes,
numPendingTests: stats.pending,
numTodoTests: stats.todo,
perfStats: {
end: new Date(stats.end).getTime(),
start: new Date(stats.start).getTime(),
Expand Down
17 changes: 17 additions & 0 deletions lib/todo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import toTestResult from './toTestResult';

const todo = ({ start, end, test }) =>
toTestResult({
stats: {
failures: 0,
pending: 0,
passes: 0,
todo: 1,
start,
end,
},
tests: [Object.assign({ duration: end - start }, test)],
jestTestPath: test.path,
});

export default todo;
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,22 @@
"format": "prettier --single-quote --trailing-comma all --write \"!(build)/**/*.js\""
},
"dependencies": {
"jest-worker": "^23.2.0",
"jest-worker": "^24.0.0",
"throat": "^4.1.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"babel-jest": "^24.0.0",
"eslint": "^5.6.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-prettier": "^3.0.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jest": "^21.15.1",
"eslint-plugin-prettier": "^2.2.0",
"execa": "^1.0.0",
"jest": "^23.6.0",
"jest": "^24.0.0",
"prettier": "^1.7.4"
}
}
Loading