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.

Jest not picking latest plugin from babel.config.js

See original GitHub issue

I have my own babel plugin mentioned in babel.config.js and when I change the plugin, jest doesn’t pick the updated plugin code and breaks tests. When I run npx jest --no-cache, updated changes are picked up.

I do not want to run with --no-cache everytime I update the plugin.

I am curious to know how jest picks the latest babel plugins, when they are updated in npm artifactory?

I have mentioned my plugin in babel.config.js as:

module.exports = function (api) {
  api.cache(true);

  const presets = ["@babel/preset-env", "@babel/preset-react"];
  const plugins = [
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-transform-runtime",
    ["module:@babel-plugin-dynamic-import-override", {
      options: someOptions
    }]
  ];

  return {
    presets,
    plugins
  };
}

Also, what changes do I make to my jest.config.js to make it pick the latest plugins?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
SimenBcommented, Sep 10, 2019

We don’t, and we won’t add it. It’s not a common use case to change the implementation of babel plugins while running tests, and we already have a way too big API. If you want you can extend babel-jest and add some sort of env variable to the getCacheKey function.

import { createTransformer } from 'babel-jest';

const transformer = createTransformer();

export = {
  ...transformer,
  getCacheKey(...args) {
    const key = transformer.getCacheKey(...args);

    return key + process.env.THING_I_CARE_ABOUT;
  },
};

https://jestjs.io/docs/en/configuration#transform-object-string-pathtotransformer-pathtotransformer-object

0reactions
github-actions[bot]commented, May 11, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest not picking latest plugin from babel.config.js
I am curious to know how jest picks the latest babel plugins, when they are updated in npm artifactory? I have mentioned my...
Read more >
babel-jest does not locate babel config when it is in root ...
js --rootDir . I get an error because I suppose that babel.config.js is not found: /packages/react-project ...
Read more >
Configuring Jest
The configuration file should simply export an object: JavaScript; TypeScript ... Node.js core modules, like fs , are not mocked by default.
Read more >
Babel Config option | ts-jest - GitHub Pages
ts-jest by default does NOT use Babel. But you may want to use it, especially if your code rely on Babel plugins to...
Read more >
jest cannot use import statement outside a module
Ended up creating a new babel.config.js file specifically for the tests. Had a large .babelrc that wasn't getting picked up by jest no...
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