Skip to content

Commit

Permalink
--findRelatedFiles (jestjs#4131)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabramov authored and cpojer committed Jul 27, 2017
1 parent a92e389 commit 3002d9c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
42 changes: 42 additions & 0 deletions integration_tests/__tests__/find_related_files.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/

'use strict';

import runJest from '../runJest';
import {cleanup, writeFiles} from '../utils';
import os from 'os';
import path from 'path';

const skipOnWindows = require('../../scripts/skip_on_windows');
const DIR = path.resolve(os.tmpdir(), 'force_exit_test');

skipOnWindows.suite();

beforeEach(() => cleanup(DIR));
afterEach(() => cleanup(DIR));

test('runs tests related to filename', () => {
writeFiles(DIR, {
'.watchmanconfig': '',
'__tests__/test.test.js': `
const a = require('../a');
test('a', () => {});
`,
'a.js': 'module.exports = {};',
'package.json': JSON.stringify({jest: {testEnvironment: 'node'}}),
});

const {stdout} = runJest(DIR, ['a.js']);
expect(stdout).toMatch(/no tests found/i);

const {stderr} = runJest(DIR, ['--findRelatedTests', 'a.js']);
expect(stderr).toMatch('PASS __tests__/test.test.js');
});
1 change: 1 addition & 0 deletions packages/jest-config/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const getConfigs = (
coverageReporters: options.coverageReporters,
coverageThreshold: options.coverageThreshold,
expand: options.expand,
findRelatedTests: options.findRelatedTests,
forceExit: options.forceExit,
json: options.json,
lastCommit: options.lastCommit,
Expand Down
1 change: 1 addition & 0 deletions packages/jest-config/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ function normalize(options: InitialOptions, argv: Argv) {
case 'coverageThreshold':
case 'expand':
case 'globals':
case 'findRelatedTests':
case 'forceExit':
case 'listTests':
case 'logHeapUsage':
Expand Down
2 changes: 2 additions & 0 deletions types/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export type InitialOptions = {|
coverageReporters?: Array<string>,
coverageThreshold?: {global: {[key: string]: number}},
expand?: boolean,
findRelatedTests?: boolean,
forceExit?: boolean,
json: boolean,
globals?: ConfigGlobals,
Expand Down Expand Up @@ -144,6 +145,7 @@ export type GlobalConfig = {|
coverageReporters: Array<string>,
coverageThreshold: {global: {[key: string]: number}},
expand: boolean,
findRelatedTests: boolean,
forceExit: boolean,
json: boolean,
lastCommit: boolean,
Expand Down

0 comments on commit 3002d9c

Please sign in to comment.