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.

[feat] Add an option to save the generated jest.config.js

See original GitHub issue

I want to be able to run jest tests from within my IDE (IDEA). It is far easier to just run jest directly than through tsdx test.

What I did was hacked a console.log() into node_modules/tsdx/lib/index.js, output the generated jest config and saved that in a jest.config.js file. Had to edit it a bit to remove the absolute paths (🤷‍♂ why those are there), but it works perfectly.

So, it would be nice to have something like the eslintconfig save option, but for the jest config.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:6
  • Comments:23 (17 by maintainers)

github_iconTop GitHub Comments

9reactions
jimmyncommented, Jan 6, 2020

@lookfirst I totally agree. I’m working in WebStorm and it has good integration with Jest but it will only work with jest.config.js present because otherwise, typescript will not compile during tests.

I ended up creating jest.config.js with

const {createJestConfig} = require('tsdx/dist/createJestConfig');
const {paths} = require('tsdx/dist/constants');

process.env.BABEL_ENV = 'test';
process.env.NODE_ENV = 'test';

module.exports = createJestConfig(undefined, paths.appRoot);

It works although it’s far from ideal solution as createJestConfig checks if jest.config.js file is present and might create a recursive loop

It would be awesome to add similar functionality to yarn lint --write-file

5reactions
jaredpalmercommented, Jan 6, 2020

Yes, tsdx test makes sense so we can upgrade jest for all of our users

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring Jest
It is recommended to define the configuration in a dedicated JavaScript, TypeScript or JSON file. The file will be discovered automatically, if ...
Read more >
Configuring Jest for Visual Studio Code - Beyond Java
Now select the second option, "Setup Jest Debug Config". It generates a launch configuration for the VS Code debugger.
Read more >
Setup Jest with Vite (featuring SWC) - Blog by hung.dev
Integrating Jest to Vite. First, generate React Typescript project using Vite. I'm gonna using npm , you can use yarn or ...
Read more >
Jest ignore or exclude file/function/statement from test coverage
Take your JavaScript testing to the next level by learning the ins ... There's a Jest configuration option testPathIgnorePatterns (see the ...
Read more >
Jest | IntelliJ IDEA Documentation - JetBrains
Optionally specify the jest.config.js or jest.config.ts file to use: select ... To do that, add the --watch flag in the Jest options field....
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