importing from src
See original GitHub issueHi,
Apologies as i am sure this a simple question but …
When i import from src e.g.
import useAsyncTaskAxios from 'react-hooks-async/src/use-async-task-axios'
this works fine in my code but not in my tests
i get SyntaxError: Unexpected identifier
guessing its because the ES6 modules not compiling but not sure how to modify my jest config to sort it out. If i import from dist
then the type information is not available?
jest.config.js
module.exports = {
"roots": [
"<rootDir>/src"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"moduleDirectories": ["node_modules", "src"],
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"reporters": [ "default", "jest-junit" ]
}
Any thoughts welcome thanks, Ed
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
How to properly import between src and test modules
You need to either configure your sys.path, or use import src.file1 If you rename src to something like my_module it would make more...
Read more >import - JavaScript - MDN Web Docs - Mozilla
In order to use the import declaration in a source file, the file must be interpreted by the runtime as a module. In...
Read more >Offer a way to import files relative to `src/` · Issue #581 - GitHub
It would be possible to configure webpack so we could import files from src/ just like import 'testUtils/myMock or maybe src/testUtils/myMock by ...
Read more >Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >importlib — The implementation of import — Python 3.11.1 ...
One is to provide the implementation of the import statement (and thus, by extension, the __import__() function) in Python source code.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Cool. Good to hear that.
I’m thinking of adding another breaking change in the API for v3. Please be patient.
Published
3.0.0-alpha.0
. Please give it a try.