I was struggling with the same problem and actually it turns out that a simple change seems to do the trick.
I just updated the moduleDirectories
field in jest.config.js
.
Before
moduleDirectories: ['node_modules']
After
moduleDirectories: ['node_modules', 'src']
Hope it helps.
More Related Contents:
- Absolute paths (baseUrl) gives error: Cannot find module
- Vscode TS language features unavailable when tests/** are not included in the tsconfig
- How can I see the full expanded contract of a Typescript type?
- Experimental decorators warning in TypeScript compilation
- What TypeScript version is Visual Studio Code using? How to update it?
- how to debug typescript files in visual studio code
- Visual Studio Code Automatic Imports
- Hide .js.map files in Visual Studio Code: File Nesting
- Jest won’t transform the module – SyntaxError: Cannot use import statement outside a module
- Setting up tsconfig with spec/test folder
- Expression ___ has changed after it was checked
- Could not find a declaration file for module ‘module-name’. ‘/path/to/module-name.js’ implicitly has an ‘any’ type
- TypeScript conditional types – filter out readonly properties / pick only required properties
- Typescript: infer type of generic after optional first generic
- Define global constants
- Create an enum with string values
- Typescript: TS7006: Parameter ‘xxx’ implicitly has an ‘any’ type
- Angular2 handling http response
- How to ‘map’ a Tuple to another Tuple type in Typescript 3.0
- Extend (Update) third-party old type declaration interface with new one
- Derive union type from tuple/array values
- Is it possible to generate string literal combinations with template literal in TypeScript?
- Test for array of string type in TypeScript
- Can’t narrow the type of an object property even after checking it with a type guard
- What do square brackets mean where a field should be in typescript?
- Angular 2 ngModel in child component updates parent component property
- How to extend the ‘Window’ typescript interface
- Getting the return type of a function which uses generics
- Self-referencing return type for static methods in inheriting classes
- How to place a dynamic component in a container