Can't find a root directory while resolving a config file path.
See original GitHub issueWhat is the current behavior?
The test suite fails to run because it can’t properly resolve the path.
Config
module.exports = {
projects: [{
displayName: 'unit',
testMatch: ['**/__tests__/unit/**/*.spec.js']
}]
}
Execution
jest --projects unit
Error: Can't find a root directory while resolving a config file path.
Provided path to resolve: unit
cwd: /Users/code/project
What is the expected behavior?
I expected that the test suite runs with the specified configuration because when I do jest --showConfig
it shows my rootDir
as /Users/code/project
which should properly resolve testMatch: ['**/__tests__/unit/**/*.spec.js']
to '/Users/code/project/__tests__/unit/**/*.spec.js'
.
I also tried to use <rootDir>
for the testMatch
but the same result and it looks like it tries to resolve the unit
as a path instead of looking it up in the jest.config.js
?
Am I supposed to put a jest.config.js
into every folder and then run jest --projects tests/unit
? If that is the case then how is the projects
option supposed to be used.
Jest, node, yarn and macOS are the latest versions.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:10
- Comments:9 (1 by maintainers)
Top GitHub Comments
@elyobo Correct. PR welcome for some way of specifying which of the loaded projects to run 🙂
Would be great to avoid duplication of identical configs in monorepos. Something like a
pathMatch
option forprojects: []
so similar sub projects can be grouped together.