Skip to content

Commit

Permalink
examples: polish some README.md (#72117)
Browse files Browse the repository at this point in the history
## Description
I have corrected some mistakes according to the [contribution
guide](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md).

1. Update `create-next-app` script
2. Remove redundant new line, space and double colon
3. `readme.md` → `README.md`

### Adding or Updating Examples

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

---------

Co-authored-by: Sam Ko <sam@vercel.com>
  • Loading branch information
2 people authored and gaojude committed Nov 13, 2024
1 parent 5c45d58 commit acc161c
Show file tree
Hide file tree
Showing 38 changed files with 505 additions and 752 deletions.
12 changes: 6 additions & 6 deletions test/development/acceptance-app/ReactRefresh.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-env jest */
import { sandbox } from 'development-sandbox'
import { createSandbox } from 'development-sandbox'
import { FileRef, nextTestSetup } from 'e2e-utils'
import path from 'path'
import { outdent } from 'outdent'
Expand All @@ -11,7 +11,9 @@ describe('ReactRefresh app', () => {
})

test('can edit a component without losing state', async () => {
const { session, cleanup } = await sandbox(next)
await using sandbox = await createSandbox(next)
const { session } = sandbox

await session.patch(
'index.js',
outdent`
Expand Down Expand Up @@ -55,11 +57,11 @@ describe('ReactRefresh app', () => {
expect(
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('Count: 2')
await cleanup()
})

test('cyclic dependencies', async () => {
const { session, cleanup } = await sandbox(next)
await using sandbox = await createSandbox(next)
const { session } = sandbox

await session.write(
'NudgeOverview.js',
Expand Down Expand Up @@ -213,7 +215,5 @@ describe('ReactRefresh app', () => {
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('Hello: 300')
expect(didFullRefresh).toBe(false)

await cleanup()
})
})
23 changes: 10 additions & 13 deletions test/development/acceptance-app/ReactRefreshLogBox-builtins.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sandbox } from 'development-sandbox'
import { createSandbox } from 'development-sandbox'
import { FileRef, nextTestSetup } from 'e2e-utils'
import path from 'path'
import { describeVariants as describe } from 'next-test-utils'
Expand All @@ -13,7 +13,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {

// Module trace is only available with webpack 5
test('Node.js builtins', async () => {
const { session, cleanup } = await sandbox(
await using sandbox = await createSandbox(
next,
new Map([
[
Expand All @@ -35,6 +35,8 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
])
)

const { session } = sandbox

await session.patch(
'index.js',
outdent`
Expand Down Expand Up @@ -71,12 +73,11 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
./app/page.js"
`)
}

await cleanup()
})

test('Module not found', async () => {
const { session, cleanup } = await sandbox(next)
await using sandbox = await createSandbox(next)
const { session } = sandbox

await session.patch(
'index.js',
Expand Down Expand Up @@ -123,12 +124,11 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
./app/page.js"
`)
}

await cleanup()
})

test('Module not found empty import trace', async () => {
const { session, cleanup } = await sandbox(next)
await using sandbox = await createSandbox(next)
const { session } = sandbox

await session.patch(
'app/page.js',
Expand Down Expand Up @@ -175,12 +175,10 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
https://nextjs.org/docs/messages/module-not-found"
`)
}

await cleanup()
})

test('Module not found missing global CSS', async () => {
const { session, cleanup } = await sandbox(
await using sandbox = await createSandbox(
next,
new Map([
[
Expand All @@ -195,6 +193,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
],
])
)
const { session } = sandbox
await session.assertHasRedbox()

const source = await session.getRedboxSource()
Expand Down Expand Up @@ -238,7 +237,5 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
expect(
await session.evaluate(() => document.documentElement.innerHTML)
).toContain('index page')

await cleanup()
})
})
12 changes: 5 additions & 7 deletions test/development/acceptance-app/ReactRefreshLogBox-scss.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-env jest */
import { sandbox } from 'development-sandbox'
import { createSandbox } from 'development-sandbox'
import { FileRef, nextTestSetup } from 'e2e-utils'
import path from 'path'
import { outdent } from 'outdent'
Expand All @@ -16,7 +16,8 @@ describe.skip('ReactRefreshLogBox scss app', () => {
})

test('scss syntax errors', async () => {
const { session, cleanup } = await sandbox(next)
await using sandbox = await createSandbox(next)
const { session } = sandbox

await session.write('index.module.scss', `.button { font-size: 5px; }`)
await session.patch(
Expand Down Expand Up @@ -44,12 +45,11 @@ describe.skip('ReactRefreshLogBox scss app', () => {
// Fix syntax error
await session.patch('index.module.scss', `.button { font-size: 5px; }`)
await session.assertNoRedbox()

await cleanup()
})

test('scss module pure selector error', async () => {
const { session, cleanup } = await sandbox(next)
await using sandbox = await createSandbox(next)
const { session } = sandbox

await session.write('index.module.scss', `.button { font-size: 5px; }`)
await session.patch(
Expand All @@ -72,7 +72,5 @@ describe.skip('ReactRefreshLogBox scss app', () => {
await session.assertHasRedbox()
const source2 = await session.getRedboxSource()
expect(source2).toMatchSnapshot()

await cleanup()
})
})
Loading

0 comments on commit acc161c

Please sign in to comment.