-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace createNextDescribe with nextTestSetup (#64817)
<!-- 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 - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating 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 # --> I took some time and [wrote a codemod](https://gist.github.com/wyattjoh/0d4464427506cb02062a4729ca906b62) that replaces the old usage of the `createNextDescribe` with the new `nextTestSetup`. You'll likely have to turn on hiding of whitespace in order to review, but this should primarily introduce no changes to the test structure other than using the new mechanism now. Closes NEXT-3178
- Loading branch information
Showing
230 changed files
with
25,830 additions
and
26,325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,38 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
import { nextTestSetup } from 'e2e-utils' | ||
import { check } from 'next-test-utils' | ||
|
||
createNextDescribe( | ||
'app-dir - app routes errors', | ||
{ | ||
describe('app-dir - app routes errors', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
}, | ||
({ next }) => { | ||
describe('bad lowercase exports', () => { | ||
it.each([ | ||
['get'], | ||
['head'], | ||
['options'], | ||
['post'], | ||
['put'], | ||
['delete'], | ||
['patch'], | ||
])( | ||
'should print an error when using lowercase %p in dev', | ||
async (method: string) => { | ||
await next.fetch('/lowercase/' + method) | ||
}) | ||
|
||
await check(() => { | ||
expect(next.cliOutput).toContain( | ||
`Detected lowercase method '${method}' in` | ||
) | ||
expect(next.cliOutput).toContain( | ||
`Export the uppercase '${method.toUpperCase()}' method name to fix this error.` | ||
) | ||
expect(next.cliOutput).toMatch( | ||
/Detected lowercase method '.+' in '.+\/route\.js'\. Export the uppercase '.+' method name to fix this error\./ | ||
) | ||
return 'yes' | ||
}, 'yes') | ||
} | ||
) | ||
}) | ||
} | ||
) | ||
describe('bad lowercase exports', () => { | ||
it.each([ | ||
['get'], | ||
['head'], | ||
['options'], | ||
['post'], | ||
['put'], | ||
['delete'], | ||
['patch'], | ||
])( | ||
'should print an error when using lowercase %p in dev', | ||
async (method: string) => { | ||
await next.fetch('/lowercase/' + method) | ||
|
||
await check(() => { | ||
expect(next.cliOutput).toContain( | ||
`Detected lowercase method '${method}' in` | ||
) | ||
expect(next.cliOutput).toContain( | ||
`Export the uppercase '${method.toUpperCase()}' method name to fix this error.` | ||
) | ||
expect(next.cliOutput).toMatch( | ||
/Detected lowercase method '.+' in '.+\/route\.js'\. Export the uppercase '.+' method name to fix this error\./ | ||
) | ||
return 'yes' | ||
}, 'yes') | ||
} | ||
) | ||
}) | ||
}) |
Oops, something went wrong.