rsnext/docs
Hung Viet Nguyen 0f873c7eea
Update Jest config with SWC docs (#37705)
## Motivation/ Context
- When upgrading `next` from `11` to `12`, I followed [Upgrade guide from 11 => 12](https://nextjs.org/docs/upgrading#upgrading-from-11-to-12). I removed `.babelrc` to opt-in `SWC`. I thought that's all, but after removing `.babelrc`, Jest broke immediately. So I follow the guide https://nextjs.org/docs/advanced-features/compiler#jest to configure Jest to work with SWC. I copied the content of `jest.config.js` to my project but it does not work. The reason:
```diff
-const createJestConfig = nextJest({ dir }) // `dir` IS NOT DEFINED
+const createJestConfig = nextJest({ dir: './' }) // Should change to this. Sync with https://nextjs.org/docs/testing#setting-up-jest-with-the-rust-compiler
```
- This PR is to help others to configure Jest with SWC by copying code from the documentation site without encountering the same issue as I did.

## Documentation
- [x] Update the docs so users can just copy and paste when configuring Jest with SWC (Sync with https://nextjs.org/docs/testing#setting-up-jest-with-the-rust-compiler)
- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

## Future work
- Since [Upgrade guide from 11 => 12](https://nextjs.org/docs/upgrading#upgrading-from-11-to-12) did not mention anything about Jest. If I remove `.babelrc` to opt-in SWC. The current Jest settings will crash (since it's using babel). We likely want to update the Upgrade guide to mention this cc: @leerob
2022-06-15 11:27:28 +00:00
..
advanced-features Update Jest config with SWC docs (#37705) 2022-06-15 11:27:28 +00:00
api-reference Fix Image Optimization cache-control regression with external images (#37625) 2022-06-13 22:13:55 +00:00
api-routes docs: Add pageExtensions usage note in API Routes (#35918) 2022-05-22 17:46:00 +00:00
basic-features Adds consistency to ESLint rules. (#34335) 2022-06-13 21:17:42 -05:00
guides Few touch-ups to the docs on web forms in Next (#34286) 2022-02-14 20:21:27 +00:00
migrating Add instructions to create pages directory and add an index.js file to it (#35971) 2022-04-15 14:40:37 +02:00
routing Update shallow routing caveat (#35052) 2022-03-07 23:29:07 +00:00
authentication.md Alphabetize auth docs providers. (#34281) 2022-02-13 00:51:53 +00:00
deployment.md Update deployment documentation. (#37571) 2022-06-08 20:46:09 +00:00
faq.md fix: change showcase url (#34590) 2022-02-19 22:33:32 +00:00
getting-started.md Update pnpm create next-app for latest pnpm 6 and 7 (#37254) 2022-05-27 21:21:40 +00:00
going-to-production.md [docs] Update going to production docs around caching headers (#35374) 2022-03-16 22:11:06 +00:00
manifest.json Move CI build cache instructions to Deployment docs (#35418) 2022-05-13 09:56:47 -04:00
testing.md Update testing.md (#29954) 2022-05-23 01:07:20 +00:00
upgrading.md Update upgrading.md (#36091) 2022-04-15 14:43:26 +02:00