TypeScript files using web-compatible ES6 imports cause Jest to throw an error about not being able to find the module. This error comes from jest-resolve/build/index.js:229 and happens regardless of the module type specified in ts-jest (commonjs, amd, ES6, etc.)
TypeScript supports adding a .js extension to import statements for web-compatibility (since imports require a full path, including the extension).
I would expect ts-jest to allow TypeScript to handle this and convert it to commonjs before it gets passed to jest.
/* user.ts */
export class User {
public name : string;
constructor(name : string) {
this.name = name;
}
}
/* user.spec.ts */
import { User } from './user.js';
describe('User', function() {
});
I facing the same issue :(
The problem it is the jest-resolve is managed by jest :(
Maybe we must to create a custom resolver for jest as workaround to solve this issue.
I set up a custom resolver and just published it to npm: jest-ts-webcompat-resolver
Most helpful comment
I set up a custom resolver and just published it to npm:
jest-ts-webcompat-resolver