-
Notifications
You must be signed in to change notification settings - Fork 204
Open
Description
I'm trying to use this plugin to handle module resolution in my Jest unit tests for a Webpack project and it works pretty well, but I can't seem to get module extensions to work. My .babelrc looks like this:
{
<...>
"env": {
"test": {
"plugins": [
["module-resolver", {
"root": ["./src", "./test"],
"extensions": [".js", ".jsx", ".json"]
}]
]
}
}
}
Then I created the file test/fixtures/foo.json
and inside of test/class/Test_spec.js
I do this:
import foo from 'fixtures/foo'
which throws this error:
Cannot find module '../fixtures/foo' from 'Test_spec.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17)
at Object.<anonymous> (test/class/Test_spec.js:6:189)
If I add the extension:
import foo from 'fixtures/foo.json'
Everything works as expected. Any suggestions would be appreciated!
Relevant versions:
λ node -v
v6.10.1
λ npm list babel-core babel-plugin-module-resolver
+-- babel-core@6.25.0
`-- babel-plugin-module-resolver@2.7.1
sjmarshy, GianniGM, drets, tmkjchen, ntharim and 10 more
Metadata
Metadata
Assignees
Labels
No labels