Skip to content

Commit

Permalink
[with-jest]: Update to use automatic path aliases (#46982)
Browse files Browse the repository at this point in the history
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

Updating the `with-jest` example to make use of the automatic path alias
feature that was added in #45815

I've also updated the dependencies in the example

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
JohnDaly and ijjk authored Mar 13, 2023
1 parent 9af72fa commit 97299a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
6 changes: 0 additions & 6 deletions examples/with-jest/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ const createJestConfig = nextJest({
// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
moduleNameMapper: {
// Handle module aliases (this will be automatically configured for you soon)
'^@/components/(.*)$': '<rootDir>/components/$1',

'^@/pages/(.*)$': '<rootDir>/pages/$1',
},
testEnvironment: 'jest-environment-jsdom',
}

Expand Down
16 changes: 8 additions & 8 deletions examples/with-jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
},
"dependencies": {
"next": "latest",
"react": "^18.1.0",
"react-dom": "^18.1.0"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "13.2.0",
"@testing-library/user-event": "14.2.0",
"@types/react": "18.0.9",
"@testing-library/react": "14.0.0",
"@testing-library/user-event": "14.4.3",
"@types/react": "18.0.28",
"@types/testing-library__jest-dom": "5.14.5",
"jest": "28.1.0",
"jest-environment-jsdom": "28.1.0",
"typescript": "4.6.4"
"jest": "29.5.0",
"jest-environment-jsdom": "29.5.0",
"typescript": "4.9.5"
}
}

0 comments on commit 97299a6

Please sign in to comment.