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.

I followed the instructions for integrating with Jest. It works.

However I got a warning:

ts-jest[main] (WARN) Replace any occurrences of “ts-jest/dist/preprocessor.js” or “<rootDir>/node_modules/ts-jest/preprocessor.js” in the ‘transform’ section of your Jest config with just “ts-jest”.

So I did that, but it doesn’t work:

transform: {
  "^.+\\.ts$": "ts-jest"
}

I also tried something I found at ts-jest, but it doesn’t work:

globals: {
  "ts-jest": {
    "compiler": "ttypescript"
  }
}

The warning implies it’s possible - with some tweaking we could avoid the preprocessor and increase speed.

Has anyone got this to work?

cc @dsherret, @Kukks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:22 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
lonix1commented, Feb 19, 2019

Hey @dsherret I just upgraded to today’s "ts-jest": "24.0.0".

I was still getting those warnings, but since it’s a new version I wanted to see if the problem is still there. So in jest.config I replaced

transform: {
    "^.+\\.ts$": "<rootDir>/.jest.tspreprocessor.js"
}

with

transform: {
    "^.+\\.ts$": "ts-jest"
}

And now the warnings go away, and the tests seem to work! So the issue is finally resolved. And no need for that preprocessor any more, so presumably the tests will be faster (though I haven’t felt a speed difference, but maybe that’s just me).

1reaction
lonix1commented, Feb 19, 2019

I can’t believe all the hoops I had to jump through to get this working properly, and yet, I’m HAPPY to have done so.

All for a single operator! Says a lot. So sorely missing from the language itself!

Kudos again for this library, what a difference it makes to my code!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started - Jest
ts-jest is a TypeScript preprocessor with source map support for Jest that lets you use Jest to test projects written in TypeScript. npm;...
Read more >
Jest Tutorial for Beginners: Getting Started With JavaScript ...
Jest is a JavaScript test runner, that is, a JavaScript library for creating, running, and structuring tests. Jest ships as an NPM package,...
Read more >
Jest Tutorial - JavaScript Unit Testing Using Jest Framework
beforeEach and afterEach: These hooks are executed before and after each test in the test suite. · Add node package for jest-html-reporter using...
Read more >
Testing TypeScript apps using Jest - LogRocket Blog
Jest is a simple, lightweight testing framework that provides a variety of testing capabilities to JavaScript and TypeScript projects. It ...
Read more >
Jest Testing Tutorial: 5 Easy Steps - Testim Blog
Get Started With Jest: A Practical, Hands-On Tutorial in 5 Steps · 1. Install Jest Globally · 2. Create a Sample Project ·...
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