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']
More Related Contents:
- Jest + Typescript + Absolute paths (baseUrl) gives error: Cannot find module
- Jest won’t transform the module – SyntaxError: Cannot use import statement outside a module
- Vscode TS language features unavailable when tests/** are not included in the tsconfig
- How do I dynamically assign properties to an object in TypeScript?
- What is “not assignable to parameter of type never” error in TypeScript?
- Is it possible to restrict TypeScript object to contain only properties defined by its class?
- Expected 3 type arguments but got 1 but it should infer 2 types
- Import class in definition file (*d.ts)
- TypeScript union of string and string literals
- Are strongly-typed functions as parameters possible in TypeScript?
- What does the `is` keyword do in typescript?
- TypeScript – use correct version of setTimeout (node vs window)
- Is there a way to “extract” the type of TypeScript interface property?
- Using latest JavaScript features in TypeScript, such as ES2018
- How to define an opaque type in TypeScript?
- Why can’t TypeScript infer type from filtered arrays?
- What is the Record type?
- Mapping tuple-typed value to different tuple-typed value without casts
- TypeScript function return type based on input parameter
- What does “homomorphic mapped type” mean?
- NPM package cannot be used as a JSX Component – Type errors
- ‘tsc command not found’ in compiling typescript
- TypeScript keyof returning specific type
- Jest – SyntaxError: Cannot use import statement outside a module
- TypeScript export imported interface
- How to create an Observable from static data similar to http one in Angular?
- Setting up tsconfig with spec/test folder
- How to pass an instance variable into typescript decorator arguments?
- Can I force the TypeScript compiler to use nominal typing?
- Optional class members in Typescript