Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'gatsby-page-utils/apply-trailing-slash-option' since Gatsby 4.7 #34784

Closed
2 tasks done
soniCaH opened this issue Feb 10, 2022 · 1 comment
Closed
2 tasks done
Labels
type: bug An issue or pull request relating to a bug in Gatsby type: upstream Issues outside of Gatsby's control, caused by dependencies

Comments

@soniCaH
Copy link

soniCaH commented Feb 10, 2022

Preliminary Checks

Description

Since I upgraded the gatsby monorepo to 4.7.1 my jest tests seems to break:

Cannot find module 'gatsby-page-utils/apply-trailing-slash-option' from 'node_modules/gatsby-link/rewrite-link-path.js'

Full error message:


    Cannot find module 'gatsby-page-utils/apply-trailing-slash-option' from 'node_modules/gatsby-link/rewrite-link-path.js'

    Require stack:
      node_modules/gatsby-link/rewrite-link-path.js
      node_modules/gatsby-link/index.js
      node_modules/gatsby/cache-dir/commonjs/gatsby-browser-entry.js
      __mocks__/gatsby.js
      src/components/player--featured.js
      src/components/__tests__/player--featured.js

      at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:324:11)
      at Object.<anonymous> (node_modules/gatsby-link/rewrite-link-path.js:8:33)

I tried adding the new trailingSlashes option to my config, but it did not fix it.

Reproduction Link

soniCaH/KCVV-Elewijt-Gatsby#657

Steps to Reproduce

  1. yarn install
  2. yarn run test

Expected Result

Jest tests pass like on Gatsby 4.6.x

Actual Result

Jest test don't pass (locally / circleci) - https://app.circleci.com/pipelines/github/soniCaH/KCVV-Elewijt-Gatsby/1934/workflows/f5494c77-ea58-4f85-9582-c8ca87a3c2b4/jobs/1910

Environment

System:
    OS: macOS 11.6
    CPU: (6) x64 Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.4.0 - /usr/local/bin/node
    Yarn: 1.22.15 - ~/.yarn/bin/yarn
    npm: 8.3.1 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 98.0.4758.80
    Firefox: 96.0.1
    Safari: 15.3
  npmPackages:
    gatsby: 4.7.1 => 4.7.1 
    gatsby-cli: 4.7.0 => 4.7.0 
    gatsby-paginate: 1.1.1 => 1.1.1 
    gatsby-plugin-google-tagmanager: 4.7.0 => 4.7.0 
    gatsby-plugin-image: 2.7.0 => 2.7.0 
    gatsby-plugin-manifest: 4.7.0 => 4.7.0 
    gatsby-plugin-netlify: next => 4.0.0-next.0 
    gatsby-plugin-offline: 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-use-query-params: 1.0.1 => 1.0.1 
    gatsby-source-drupal: 5.7.0 => 5.7.0 
    gatsby-source-filesystem: 4.7.0 => 4.7.0 
    gatsby-transformer-sharp: 4.7.0 => 4.7.0 
  npmGlobalPackages:
    gatsby-cli: 2.8.14
    gatsby: 2.18.5

Config Flags

FAST_DEV: true

@soniCaH soniCaH added the type: bug An issue or pull request relating to a bug in Gatsby label Feb 10, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Feb 10, 2022
@LekoArts LekoArts removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Feb 10, 2022
@LekoArts
Copy link
Contributor

Hi!

Please see the release notes here: https://www.gatsbyjs.com/docs/reference/release-notes/v4.7/#trailingslash-option

If you’re unit testing gatsby-link you’ll need to update the moduleNameMapper option to include gatsby-page-utils, see Unit Testing documentation for more details.

You'll want to add "^gatsby-page-utils/(.*)$": "gatsby-page-utils/dist/$1" to moduleNameMapper to workaround the issue jestjs/jest#9771

@LekoArts LekoArts added the type: upstream Issues outside of Gatsby's control, caused by dependencies label Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby type: upstream Issues outside of Gatsby's control, caused by dependencies
Projects
None yet
Development

No branches or pull requests

2 participants