-
Preliminary Checks
DescriptionBy following this guide to setup tests, I recently get this error:
The reason is that the dependency offers the method only in a var _applyTrailingSlashOption = require("gatsby-page-utils/dist/apply-trailing-slash-option"); Versions are:
Both published 3 days ago according to npm. Reproduction LinkSteps to Reproduce
Expected ResultThe test passes Actual ResultThe test fails EnvironmentSystem:
OS: macOS 12.2.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
Languages:
Python: 2.7.18 - /usr/bin/python
Browsers:
Chrome: 98.0.4758.80
Firefox: 96.0.3
Safari: 15.3
npmPackages:
gatsby: ^4.7.1 => 4.7.1
gatsby-plugin-gdpr-cookies: ^2.0.8 => 2.0.8
gatsby-plugin-image: ^2.7.0 => 2.7.0
gatsby-plugin-local-search: ^2.0.1 => 2.0.1
gatsby-plugin-netlify: ^4.1.0 => 4.1.0
gatsby-plugin-purgecss: ^6.1.0 => 6.1.0
gatsby-plugin-react-helmet: ^5.7.0 => 5.7.0
gatsby-plugin-sass: ^5.7.0 => 5.7.0
gatsby-plugin-sharp: ^4.7.0 => 4.7.0
gatsby-plugin-sitemap: ^5.7.0 => 5.7.0
gatsby-plugin-use-query-params: ^1.0.1 => 1.0.1
gatsby-source-contentful: ^7.5.0 => 7.5.0
gatsby-source-shopify: ^6.7.0 => 6.7.0
gatsby-transformer-sharp: ^4.7.0 => 4.7.0
npmGlobalPackages:
gatsby: 4.7.1 Config FlagsNo response |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
In step 2 (https://www.gatsbyjs.com/docs/how-to/testing/unit-testing/#2-creating-a-configuration-file-for-jest) you need to make sure to set the "^gatsby-core-utils/(.*)$": `gatsby-core-utils/dist/$1`, // Workaround for https://github.com/facebook/jest/issues/9771
"^gatsby-plugin-utils/(.*)$": [
`gatsby-plugin-utils/dist/$1`,
`gatsby-plugin-utils/$1`,
], // Workaround for https://github.com/facebook/jest/issues/9771 |
Beta Was this translation helpful? Give feedback.
-
Hi, It also happens when we use |
Beta Was this translation helpful? Give feedback.
-
No longer needed per Jest@28, Gatsby docs have also been updated
|
Beta Was this translation helpful? Give feedback.
-
I resolved the issue on my side by modifying this in
To this
|
Beta Was this translation helpful? Give feedback.
In step 2 (https://www.gatsbyjs.com/docs/how-to/testing/unit-testing/#2-creating-a-configuration-file-for-jest) you need to make sure to set the
moduleNameMapper
correctly and include: