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']
Related Contents:
- Jest + Typescript + Absolute paths (baseUrl) gives error: Cannot find module
- Cannot find name ‘describe’. Do you need to install type definitions for a test runner?
- How do you debug Jest Tests?
- Jest won’t transform the module – SyntaxError: Cannot use import statement outside a module
- Problem with Visual Studio Code using “react-jsx” as jsx value with create-react-app
- Cypress causing type errors in jest assertions
- Jest did not exit one second after the test run has completed using express
- jest typescript property mock does not exist on type
- create-react-app Typescript 3.5, Path Alias
- Cannot find name ‘it’ in Jest TypeScript
- Mock a typescript interface with jest
- How to Use `import.meta` When Testing With Jest
- JEST – SyntaxError: Unexpected token ‘export’ with uuid library
- ts-jest does not recognize es6 imports
- Configure Jest global tests setup with .ts file
- How to mock React Navigation’s navigation prop for unit tests with TypeScript in React Native?
- How to implement class constants?
- Define global constants
- What is the shortcut in Visual Studio Code for console.log
- What return type should be used for setTimeout in TypeScript?
- Test for array of string type in TypeScript
- vscode imports import console = require(“console”); automatically
- What does the pipe(|) mean in typescript?
- Need clarification of the target and lib compiler options
- NPM package cannot be used as a JSX Component – Type errors
- Angular 2 custom form input
- What’s the meaning of “=>” in TypeScript? (Fat Arrow)
- typescript outDir setting in tsconfig.json not working
- How to use Promise.all() with Typescript
- How to map over union array type?
- How to merge two enums in TypeScript
- Creating model classes in TypeScript
- Generic Object type in typescript
- What is the difference between never and void in typescript?
- How to import all modules from a directory in TypeScript?
- TypeORM: update item and return it
- Can an optional parameter be null in TypeScript?
- What does -? mean in TypeScript?
- Only ‘amd’ and ‘system’ modules are supported alongside –out
- How to place a dynamic component in a container
- Embed TypeScript code in an HTML document
- How do I fix error TS1015: Parameter cannot have question mark and initializer?
- Jest – SyntaxError: Cannot use import statement outside a module
- Angular 2 View will not update after variable change in subscribe
- Difference b/w only Exclude and Omit (Pick & Exclude) Typescript
- How to run typescript compiler as a package.json script without grunt or gulp
- using absolute paths in typescript for imports
- Typescript – interface extending another interface with nested properties
- Check if checkbox element is checked in TypeScript
- What is the equivalent of protected in TypeScript?