Skip to content

Commit 774ccaa

Browse files
authored
Merge pull request #2 from TheBrainFamily/master
Expose ability to skip tests
2 parents 671ee33 + 87a7c6e commit 774ccaa

File tree

7 files changed

+44
-1
lines changed

7 files changed

+44
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// 🙈
2+
console.log()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
runner: require.resolve('../../runner'),
3+
testMatch: ['**/__src__/**/*.js'],
4+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Works when it has skipped tests 1`] = `
4+
"Test Suites: 1 skipped, 0 of 1 total
5+
Tests: 1 skipped, 1 total
6+
Snapshots: 0 total
7+
Time:
8+
Ran all test suites.
9+
"
10+
`;

integrationTests/runner/run.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const fs = require('fs');
2-
const { pass, fail } = require('../../');
2+
const { pass, fail, skip } = require('../../');
33

44
module.exports = ({ testPath }) => {
55
const start = +new Date();
@@ -9,6 +9,9 @@ module.exports = ({ testPath }) => {
99
if (contents.includes('⚔️🏃')) {
1010
return pass({ start, end, test: { path: testPath } });
1111
}
12+
if (contents.includes('🙈')) {
13+
return skip({ start, end, test: { path: testPath } });
14+
}
1215
const errorMessage = 'Company policies require ⚔️ 🏃 in every file';
1316
return fail({
1417
start,

integrationTests/skipped.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const runJest = require('./runJest');
2+
3+
it('Works when it has skipped tests', () => {
4+
return expect(runJest('skipped')).resolves.toMatchSnapshot();
5+
});

lib/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
const createJestRunner = require('./createJestRunner');
22
const fail = require('./fail');
33
const pass = require('./pass');
4+
const skip = require('./skip');
45

56
module.exports = {
67
createJestRunner,
78
fail,
89
pass,
10+
skip,
911
};

lib/skip.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const toTestResult = require('./toTestResult');
2+
3+
const skip = ({ start, end, test }) =>
4+
toTestResult({
5+
stats: {
6+
failures: 0,
7+
pending: 1,
8+
passes: 0,
9+
start,
10+
end,
11+
},
12+
skipped: true,
13+
tests: [Object.assign({ duration: end - start }, test)],
14+
jestTestPath: test.path,
15+
});
16+
17+
module.exports = skip;

0 commit comments

Comments
 (0)