Skip to content

Commit f29ffb0

Browse files
authored
chore(docs): Update Unit Testing instructions to update moduleNameMapper (#34775)
1 parent f720571 commit f29ffb0

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

docs/docs/how-to/testing/unit-testing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module.exports = {
4242
moduleNameMapper: {
4343
".+\\.(css|styl|less|sass|scss)$": `identity-obj-proxy`,
4444
".+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": `<rootDir>/__mocks__/file-mock.js`,
45+
"^gatsby-page-utils/(.*)$": `gatsby-page-utils/dist/$1`, // Workaround for https://github.com/facebook/jest/issues/9771
4546
},
4647
testPathIgnorePatterns: [`node_modules`, `\\.cache`, `<rootDir>.*/public`],
4748
transformIgnorePatterns: [`node_modules/(?!(gatsby)/)`],

docs/docs/reference/release-notes/v4.7/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if you have any [issues](https://github.com/gatsbyjs/gatsby/issues).
2424

2525
## `trailingSlash` Option
2626

27-
_Currently in public Beta_
27+
_Currently in Public Beta_
2828

2929
Through the RFC [Integrated handling of trailing slashes in Gatsby](https://github.com/gatsbyjs/gatsby/discussions/34205) we've worked on making the trailing slashes feature a first-class citizen in Gatsby. We're happy to announce that `gatsby-config` now supports a `trailingSlash` configuration with these three main options:
3030

@@ -40,11 +40,11 @@ module.exports = {
4040
}
4141
```
4242

43-
Throughout Gatsby 4 the default setting for `trailingSlash` will be `legacy` (to keep the current behavior) but with Gatsby 5 we'll remove the `legacy` setting and make `always` the default.
43+
Throughout Gatsby 4 the default setting for `trailingSlash` will be `legacy` (to keep the current behavior) but with Gatsby 5 we'll remove the `legacy` setting and make `always` the default. Please note that these plugins are considered deprecated now: [gatsby-plugin-force-trailing-slashes](/plugins/gatsby-plugin-force-trailing-slashes/) and [gatsby-plugin-remove-trailing-slashes](/plugins/gatsby-plugin-remove-trailing-slashes/).
4444

4545
Gatsby Cloud supports this new setting out of the box and also uses `301` redirects to bring visitors to the right location. Locally you can use `gatsby serve` to see the behavior. Any other hosting provider (or if you’re managing this on your own) should follow the “Redirects, and expected behavior from the hosting provider” section on the [initial RFC](https://github.com/gatsbyjs/gatsby/discussions/34205).
4646

47-
Please note that these plugins are considered deprecated now: [gatsby-plugin-force-trailing-slashes](/plugins/gatsby-plugin-force-trailing-slashes/) and [gatsby-plugin-remove-trailing-slashes](/plugins/gatsby-plugin-remove-trailing-slashes/).
47+
If you're unit testing `gatsby-link` you'll need to update the `moduleNameMapper` option to include `gatsby-page-utils`, see [Unit Testing documentation](/docs/how-to/testing/unit-testing/#2-creating-a-configuration-file-for-jest) for more details.
4848

4949
The information presented here is also available in the [gatsby-config docs page](/docs/reference/config-files/gatsby-config/#trailingslash) and in the [PR #34268](https://github.com/gatsbyjs/gatsby/pull/34268) that implemented this.
5050

examples/using-jest/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
moduleNameMapper: {
66
".+\\.(css|styl|less|sass|scss)$": `identity-obj-proxy`,
77
".+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": `<rootDir>/__mocks__/file-mock.js`,
8+
"^gatsby-page-utils/(.*)$": `gatsby-page-utils/dist/$1`, // Workaround for https://github.com/facebook/jest/issues/9771
89
},
910
testPathIgnorePatterns: [`node_modules`, `.cache`],
1011
transformIgnorePatterns: [`node_modules/(?!(gatsby)/)`],

0 commit comments

Comments
 (0)