question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ts-jest fails to work with TS 3.7.2

See original GitHub issue

Issue :

When I’ve updated my deps, the tests stopped working. I have a custom monorepo setup with TS references, Jest projects and ttypescript compiler to rewrite @paths on compile.

 FAIL  packages/core/tests/functional/bar.ts
  ● Test suite failed to run

    Cannot find module '@typegraphql/core' from 'bar.ts'  

    > 1 | import { bar } from "@typegraphql/core";        
        | ^
      2 | 
      3 | describe("bar", () => {
      4 |   it("should return 'bar'", () => {

      at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:259:17)

When I’ve downgraded the TS deps to 3.6.3, it works as earlier:

 PASS  tests/functional/bar.ts
 PASS  tests/functional/foo.ts

Test Suites: 2 passed, 2 total
Tests:       2 passed, 2 total

I’ve created two branches that you can checkout and reproduce: https://github.com/MichalLytek/type-graphql/tree/ts-jest-3.7.2 https://github.com/MichalLytek/type-graphql/tree/ts-jest-3.6.3

Expected behavior :

It should work as before upgrade.

Minimal repo :

https://github.com/MichalLytek/type-graphql/tree/ts-jest-3.7.2 https://github.com/MichalLytek/type-graphql/tree/ts-jest-3.6.3

git clone
npm i (on root folder)
npm run bootstrap
cd packages/core
npx jest --watch

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:7

github_iconTop GitHub Comments

5reactions
jasonkuhrtcommented, Nov 12, 2019

Hey @MichalLytek 😃

I’m hitting a similar-seeming issue. In my project I do not have this error in VSCode, just from ts-jest.

image

But It might not be related as I downgraded to 3.6 and still have this error. My case doesn’t seem to be tied to 3.7.

0reactions
ahnpnlcommented, Jan 15, 2020

please do these following steps:

  • Create a tsconfig.spec.json which extends tsconfig.json
  • Specifying ts-jest config to use that tsconfig.spec.json
  • Add module: commonjs and target: es2020 (don’t use target: esnext) to this tsconfig.spec.json.
  • Clear jest cache
  • Rerun tests
Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest errors when trying to run TypeScript Tests - Stack Overflow
When trying to run my tests in a dual client / server repo, I'm getting the following error that I can't seem to...
Read more >
ts-jest - npm
ts -jest. A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript. NPM version NPM...
Read more >
Diagnostics option | ts-jest - GitHub Pages
The diagnostics option configures error reporting. ... If a diagnostic is not filtered out, ts-jest will fail the compilation and your test.
Read more >
jest encountered an unexpected token ts-jest - You.com
Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest...
Read more >
How to Test TypeScript with Jest - Medium
Install ts-jest and @types/jest into your project by running the following command: ... However, this will not work with TypeScript.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found