Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[25.3.1]: "Emit skipped" Error #1500

Closed
le0nik opened this issue Apr 4, 2020 · 12 comments · Fixed by #1502
Closed

[25.3.1]: "Emit skipped" Error #1500

le0nik opened this issue Apr 4, 2020 · 12 comments · Fixed by #1502
Labels
🐛 Bug Confirmed Bug is confirmed

Comments

@le0nik
Copy link

le0nik commented Apr 4, 2020

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"
@le0nik le0nik added Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Apr 4, 2020
@le0nik le0nik changed the title [23.3.1]: "Emit skipped" [23.3.1]: "Emit skipped" Error Apr 4, 2020
@ahnpnl
Copy link
Collaborator

ahnpnl commented Apr 4, 2020

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.

@ahnpnl ahnpnl added 🐛 Bug Confirmed Bug is confirmed and removed Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Apr 4, 2020
@le0nik
Copy link
Author

le0nik commented Apr 4, 2020

Hi, thank you for suggesting this workaround. Adding outDir to tsconfig.json worked.

@yoursunny
Copy link

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

@jngk2
Copy link

jngk2 commented Jun 18, 2020

Similar to the above, I was missing @types/ts-jest

iamssen pushed a commit to rocket-hangar/rocket-scripts that referenced this issue Jul 31, 2020
iamssen pushed a commit to rocket-hangar/rocket-scripts that referenced this issue Jul 31, 2020
iamssen pushed a commit to rocket-hangar/rocket-scripts that referenced this issue Jul 31, 2020
iamssen pushed a commit to rocket-hangar/rocket-scripts that referenced this issue Jul 31, 2020
@mlg87
Copy link

mlg87 commented Aug 17, 2020

Similar to the above, I was missing @types/ts-jest

@jngk2 is that the correct pkg name? i dont see ts-jest in definitelyTyped

@olingern
Copy link

I also ran into this. Removing noEmitError in tsconfig.json fixed this for me.

@BabkinAleksandr
Copy link

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

@BorntraegerMarc
Copy link

I solve this issue by simply deleting my whole git project and re-cloning it 😕

@narthur
Copy link

narthur commented Jan 21, 2021

Restarting my jest test watcher fixed the issue for me.

@johan
Copy link

johan commented Apr 5, 2021

Another solution for projects where you are using both js and ts in your tests, and had this working in typescript 4.0 with the js-with-ts preset, where you probably ought to have set that up with babel instead, to get it running with typescript 4.2:

-const tsjest = require("ts-jest/presets/js-with-ts/jest-preset");
+const tsjest = require("ts-jest/presets/js-with-babel/jest-preset");

@Elias-Graf
Copy link

Elias-Graf commented Apr 12, 2021

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

This doens't just apply to index files, it applies to all files. I had a useChanger.tsx and a useChanger.ts and the error occurred.

Horrible error message btw, I'm sure that could be improved.

@16oh4
Copy link

16oh4 commented Oct 25, 2021

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

Also ran into this issue. Does tsc have a compile-time error for this, or is ts-jest merely "masking" the error?

@ahnpnl is there a way we can always see the output of tsc without being masked by ts-jest (if that is the case for some errors)?

Seems like the types error reporting could be better handled (either in ts-jest or tsc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Confirmed Bug is confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.