Skip to content

Commit

Permalink
invert the logic
Browse files Browse the repository at this point in the history
  • Loading branch information
EnoahNetzach committed May 30, 2017
1 parent 8fdfe5c commit c87e010
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion integration_tests/__tests__/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test('config as JSON', () => {
]);
const stdout = result.stdout.toString();

expect(result.status).toBe(0);
expect(result.status).toBe(1);
expect(stdout).toMatch('No tests found');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ const runJest = require('../runJest');

const DIR = path.resolve(__dirname, '../failWithNoTests');

describe('jest --failWithNoTests', () => {
test("doesn't fail the test suite if no files are found", () => {
describe('jest --passWithNoTests', () => {
test('fails the test suite if no files are found', () => {
const result = runJest(DIR, ['--testPathPattern', '/non/existing/path/']);
const status = result.status;
const stdout = result.stdout.toString();

expect(stdout).toMatch('No tests found');
expect(status).toBe(0);
expect(status).toBe(1);
});

test('fails the test suite if no files are found', () => {
test("doesn't fail the test suite if no files are found", () => {
const result = runJest(DIR, [
'--testPathPattern',
'/non/existing/path/',
'--failWithNoTests',
'--passWithNoTests',
]);
const status = result.status;
const stdout = result.stdout.toString();

expect(stdout).toMatch('No tests found');
expect(status).toBe(1);
expect(status).toBe(0);
});
});
10 changes: 5 additions & 5 deletions packages/jest-cli/src/cli/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,6 @@ const options = {
description: 'Use this flag to show full diffs instead of a patch.',
type: 'boolean',
},
failWithNoTests: {
default: false,
description: 'Will fail if no tests are found (for example while using `--testPathPattern`.)',
type: 'boolean',
},
findRelatedTests: {
default: undefined,
description: 'Find related tests for a list of source files that were ' +
Expand Down Expand Up @@ -290,6 +285,11 @@ const options = {
'also specified.',
type: 'string',
},
passWithNoTests: {
default: false,
description: 'Will not fail if no tests are found (for example while using `--testPathPattern`.)',
type: 'boolean',
},
preset: {
description: "A preset that is used as a base for Jest's configuration.",
type: 'string',
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-cli/src/runJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ const runJest = async (
if (!allTests.length) {
const noTestsFoundMessage = getNoTestsFoundMessage(testRunData, pattern);

if (argv.failWithNoTests) {
if (argv.passWithNoTests) {
new Console(pipe, pipe).log(noTestsFoundMessage);
} else {
new Console(pipe, pipe).error(noTestsFoundMessage);

process.exit(1);
} else {
new Console(pipe, pipe).log(noTestsFoundMessage);
}
} else if (
allTests.length === 1 &&
Expand Down

0 comments on commit c87e010

Please sign in to comment.