Tests fail with "Emit skipped" error when in Progam mode and "Emit skipped for language service" in LanguageService mode.
Works correctly with 23.2.1.
FAIL src/__tests__/Tree.test.tsx
โ Test suite failed to run
TypeError: src/testing/mocks/loadershim.js: Emit skipped
at compileFn (node_modules/ts-jest/dist/compiler/program.js:137:23)
at Object.compile (node_modules/ts-jest/dist/compiler/instance.js:90:25)
at TsJestTransformer.process (node_modules/ts-jest/dist/ts-jest-transformer.js:94:41)
at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:446:35)
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:525:40)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:563:25)
src/testing/mocks/loadershim.js
global.___loader = {
enqueue: jest.fn(),
};
jest.config.js
module.exports = {
preset: 'ts-jest/presets/js-with-ts',
transform: {},
testEnvironment: 'jsdom',
setupFiles: [
'<rootDir>/src/testing/mocks/loadershim.js',
'<rootDir>/src/testing/mocks/react-transition-group-mock.js',
],
setupFilesAfterEnv: ['<rootDir>/src/testing/setup.ts'],
roots: ['<rootDir>/src/'],
moduleNameMapper: {
'.+\\.(css|styl|less|sass|scss)$': 'identity-obj-proxy',
'.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/src/testing/mocks/file-mock.js',
},
testPathIgnorePatterns: ['node_modules', '.cache'],
transformIgnorePatterns: ['node_modules/(?!(gatsby)/)'],
globals: {
__PATH_PREFIX__: '',
'ts-jest': {
babelConfig: true,
tsConfig: 'tsconfig.json',
isolatedModules: false,
compilerHost: true,
incremental: true,
},
},
};
tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"lib": ["esnext", "dom"],
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"allowSyntheticDefaultImports": true,
"isolatedModules": true,
"allowJs": true,
"esModuleInterop": true,
"disableSizeLimit": true,
"jsx": "preserve"
},
"include": ["."],
"exclude": ["node_modules", "public", ".cache", "data", "static"]
}
deps:
"ts-jest": "25.3.1",
"typescript": "3.8.3"
"jest": "25.2.7",
"@babel/core": "7.9.0"
Hi, thank you for submitting the issue. You can try to set outDir in your tsconfig. We suspected that allowJs: true requires outDir to be set in tsconfig.
Hi, thank you for suggesting this workaround. Adding outDir to tsconfig.json worked.
I encountered this Emit skipped for language service error.
In my case, the cause is: tsconfig.json compilerOptions.types contains a non-existent package.
Deleting that package name and ts-jest is working again.
FYI
Similar to the above, I was missing @types/ts-jest
Similar to the above, I was missing @types/ts-jest
@jngk2 is that the correct pkg name? i dont see ts-jest in definitelyTyped
I also ran into this. Removing noEmitError in tsconfig.json fixed this for me.
Also faced it. But I accidently had multiple index files: index.ts and index.tsx and it's suddenly resulted in this error
Hope it'll help somebody
Most helpful comment
I also ran into this. Removing
noEmitErrorintsconfig.jsonfixed this for me.