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.

Load jest-puppeteer.config.js from <rootDir>

See original GitHub issue

šŸš€ Feature Proposal

When I place my Jest config in a sub-directory my tests actually have a new <rootDir>, but the jest-puppeteer.config.js is still loaded from the root of my project.

- jest-puppeteer.config.js
- tests/jest.config.js

$ jest --config tests/jest.config.js

It would be nice however, if I could do this by default.

- tests/jest-puppeteer.config.js
- tests/jest.config.js

$ jest --config tests/jest.config.js

Motivation

IMHO it is more natural to respect the <rootDir> of Jest and easier to learn/to ā€œdo rightā€. Currently I can set JEST_PUPPETEER_CONFIG, but this is something I need to look up and it is also less ā€œshareableā€.

An alternative to get rid of JEST_PUPPETEER_CONFIG in the case you donā€™t wanā€™t to respect <rootDir> by default would be to make it configurable similar to how ts-jest handles the tsconfig.json:

module.exports = {
  globals: {
    'jest-puppeteer': {
      config: '<rootDir>/jest-puppeteer.config.js'
    }
  }
};

That is still something I need to look up, but at least it is easier to share and I can use <rootDir>.

Example

If you donā€™t place your Jest configs in sub-directories everything still works like usual:

- jest-puppeteer.config.js
- jest.config.js

$ jest

If you do place your Jest configs in sub-directories, you can place the corresponding jest-puppeteer.config.js in the same directory without the need to add custom environment variables.

- tests/jest-puppeteer.config.js
- tests/jest.config.js

$ jest --config tests/jest.config.js

Pitch

Why does this feature belong in the SVGR ecosystem?

What is the SVGR ecosystem?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Macilcommented, May 13, 2019

Right now, you can make jest-puppeteer load jest-puppeteer.config.js from the same directory as jest.config.js by putting this in your jest.config.js:

process.env.JEST_PUPPETEER_CONFIG = require.resolve('./jest-puppeteer.config.js');

(Iā€™d love it if this wasnā€™t necessary and was the default behavior.)

0reactions
thernstigcommented, Nov 29, 2019

@gregberge https://github.com/smooth-code/jest-puppeteer#jest-puppeteerconfigjs specifically says:

You can specify a jest-puppeteer.config.js at the root of the project

Considering ā€œrootā€ is often used as ā€œrootDirā€ in Jest config and also if you use the ā€˜projectsā€™ property, it would be nice to at least use <rootDir> in the code where it is called.

I understand you might want to get rid of jest-puppeteer.config.js but as the issue was submitted a year ago, maybe this could be considered anyway as it makes it more natural than using the env var?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring Jest
Use the <rootDir> string token to include the path to your project's root directory. JavaScript; TypeScript. /** @type {import('jest').Config}Ā ...
Read more >
Puppeteer Jest Cloud Testing - TestingBot
Configure Jest with Puppeteer. To configure Jest Puppeteer, create a new file called jest-puppeteer.config.js and add this to the file:.
Read more >
Building and starting 2 apps in GitHub Actions using jest ...
Here are my config files. jest.config.js module.exports = { preset: 'jest-puppeteer',Ā ...
Read more >
Move jest.conf Out of Root Directory - Bambielli's Blog
js or .jsx through babel, so they are transpiled to node-compatible javascript. Notice the <rootDir> prepended to the babel-jest path aboveĀ ...
Read more >
Run Your Tests using Jest & Puppeteer - Morioh
To use it, specify a server section in your jest-puppeteer.config.js . ... #FALSE; #kludge: ViewPlot doesn't load drill files that are too small...
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