Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

It's a babel issue and the name of the plugin that is causing this error to appear is gatsby-wpgraphql-inline-images. The plugin works amazingly but its files are not transformed by babel and they need to be in order to work with jest.

In my jest config file gatsby docs recommend using this pattern which makes the test not fail with all kinds of errors:

transformIgnorePatterns: ["node_modules/(?!(gatsby))"],

This means gatsby's code is all transformed and this pattern ignores all the folders with the word gatsby in them, hover this also means that this plugins files also get ignored. Because of that, the files in the plugin directory are not being transformed and they need to be. So I'm looking for some help on how to say with regex, ignore all the folders that have the word "gatsby" in them except the one named gatsby-wpgraphql-inline-images.

Thank you!

** Update ** got it working!! I realized from the Gatsby source docs that all the Gatsby source files are also un-transpiled es6 code. I tried adding the following line to see if it would catch both "gatsby" folders and the plugin folder with the name gatsby-wpgraphql-inline-images and it worked! For some reason even though the plugin has the word Gatsby in it, jest was not adding it in to be transpiled.

 transformIgnorePatterns: [
    "node_modules/(?!(gatsby-wpgraphql-inline-images))"

Now everything is being transpiled during my jest tests. Hope this helps anyone else. Cheers!

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.