forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
133 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* 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(), 'run_tests_by_path_test'); | ||
|
||
skipOnWindows.suite(); | ||
|
||
beforeEach(() => cleanup(DIR)); | ||
afterEach(() => cleanup(DIR)); | ||
|
||
test('runs tests by exact path', () => { | ||
writeFiles(DIR, { | ||
'.watchmanconfig': '', | ||
'__tests__/t1.test.js': 'it("foo", () => {})', | ||
'__tests__/t2.test.js': 'it("bar", () => {})', | ||
'package.json': JSON.stringify({jest: {testEnvironment: 'node'}}), | ||
}); | ||
|
||
// Passing an exact path executes only the given test. | ||
const run1 = runJest(DIR, ['--runTestsByPath', '__tests__/t1.test.js']); | ||
expect(run1.stderr).toMatch('PASS __tests__/t1.test.js'); | ||
expect(run1.stderr).not.toMatch('PASS __tests__/t2.test.js'); | ||
|
||
// When running with thte flag and a pattern, no test is found. | ||
const run2 = runJest(DIR, ['--runTestsByPath', '__tests__/t']); | ||
expect(run2.stdout).toMatch(/no tests found/i); | ||
|
||
// When ran without the flag and a pattern, both tests are found. | ||
const run3 = runJest(DIR, ['__tests__/t']); | ||
expect(run3.stderr).toMatch('PASS __tests__/t1.test.js'); | ||
expect(run3.stderr).toMatch('PASS __tests__/t2.test.js'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters