-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
1 parent
36be0ba
commit b067bc6
Showing
11 changed files
with
121 additions
and
1 deletion.
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,60 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {resolve} from 'path'; | ||
|
||
import {json as runWithJson} from '../runJest'; | ||
|
||
const dir = resolve(__dirname, '..', 'run-projects'); | ||
|
||
test('run first project when runProjects is [first-project]', () => { | ||
const {json} = runWithJson('run-projects', [ | ||
`--runProjects`, | ||
'first-project', | ||
]); | ||
expect(json.success).toBe(true); | ||
expect(json.numTotalTests).toBe(1); | ||
expect(json.testResults.map(({name}) => name)).toEqual([ | ||
resolve(dir, '__tests__/first-project.test.js'), | ||
]); | ||
}); | ||
|
||
test('run second project when runProjects is [second-project]', () => { | ||
const {json} = runWithJson('run-projects', [ | ||
'--runProjects', | ||
'second-project', | ||
]); | ||
expect(json.success).toBe(true); | ||
expect(json.numTotalTests).toBe(1); | ||
expect(json.testResults.map(({name}) => name)).toEqual([ | ||
resolve(dir, '__tests__/second-project.test.js'), | ||
]); | ||
}); | ||
|
||
test('run first and second project when runProjects is [first-project, second-project]', () => { | ||
const {json} = runWithJson('run-projects', [ | ||
'--runProjects', | ||
'first-project', | ||
'second-project', | ||
]); | ||
expect(json.success).toBe(true); | ||
expect(json.numTotalTests).toBe(2); | ||
expect(json.testResults.map(({name}) => name).sort()).toEqual([ | ||
resolve(dir, '__tests__/first-project.test.js'), | ||
resolve(dir, '__tests__/second-project.test.js'), | ||
]); | ||
}); | ||
|
||
test('run first and second project when runProjects is not specified', () => { | ||
const {json} = runWithJson('run-projects', []); | ||
expect(json.success).toBe(true); | ||
expect(json.numTotalTests).toBe(2); | ||
expect(json.testResults.map(({name}) => name).sort()).toEqual([ | ||
resolve(dir, '__tests__/first-project.test.js'), | ||
resolve(dir, '__tests__/second-project.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
it('should run when first-project appears in runProjects', () => { | ||
expect(true).toBe(true); | ||
}); |
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,3 @@ | ||
it('should run when second-project appears in runProjects', () => { | ||
expect(true).toBe(true); | ||
}); |
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,16 @@ | ||
{ | ||
"jest": { | ||
"projects": [ | ||
{ | ||
"name": "first-project", | ||
"testMatch": ["<rootDir>/__tests__/first-project.test.js"], | ||
"testEnvironment": "node" | ||
}, | ||
{ | ||
"name": "second-project", | ||
"testMatch": ["<rootDir>/__tests__/second-project.test.js"], | ||
"testEnvironment": "node" | ||
} | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {Config} from '@jest/types'; | ||
|
||
export default function getConfigsOfProjectsToRun( | ||
argv: Config.Argv, | ||
projectConfigs: Array<Config.ProjectConfig>, | ||
): Array<Config.ProjectConfig> { | ||
if (!argv.runProjects) { | ||
return projectConfigs; | ||
} | ||
const namesOfProjectsToRun = new Set(argv.runProjects); | ||
return projectConfigs.filter(config => namesOfProjectsToRun.has(config.name)); | ||
} |
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