Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover 1st-party examples with tests #45270

Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
df87d54
Test selected examples
jankaifer Jan 25, 2023
6487a71
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Jan 25, 2023
4adcd49
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Jan 26, 2023
d6b5a55
add the rest of the examples
jankaifer Jan 27, 2023
d539b41
TYPOs
jankaifer Jan 27, 2023
a1be69e
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Jan 27, 2023
07ba14d
add better logs
jankaifer Jan 27, 2023
daadd6b
fix using-router example
jankaifer Jan 27, 2023
9c97eff
fix dep versions in example
jankaifer Jan 27, 2023
0bfa744
fix outdated deps in example
jankaifer Jan 27, 2023
9214bca
fix unhandled uninitialized var in example
jankaifer Jan 27, 2023
9ee2286
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Jan 27, 2023
4470e8d
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Jan 30, 2023
c3a4dd7
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Feb 2, 2023
c1e6c23
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
kodiakhq[bot] Feb 2, 2023
6e02849
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Feb 2, 2023
0a76e55
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Feb 3, 2023
2850d4f
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Feb 6, 2023
c424ed6
split test into multiple files for performance reasons
jankaifer Feb 6, 2023
7c92114
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Feb 6, 2023
db1f050
reduce number of examples run
jankaifer Feb 6, 2023
3c883e8
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Feb 7, 2023
6b33638
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Feb 7, 2023
404c026
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Feb 14, 2023
10b7f10
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
timneutkens Feb 14, 2023
c9a9696
wip make standalowne workflow for examples
jankaifer Feb 15, 2023
af2e484
refactor example tests
jankaifer Feb 15, 2023
e052d7f
don't execute with cron on forks
jankaifer Feb 15, 2023
f220ab8
better comment
jankaifer Feb 15, 2023
98f5a57
wip
jankaifer Feb 15, 2023
40ef8b7
removed strict equal
jankaifer Feb 15, 2023
c2f6966
fixed copy-pasta
jankaifer Feb 15, 2023
f07baa0
wip
jankaifer Feb 15, 2023
7dda882
wip
jankaifer Feb 15, 2023
70dd3c7
remove unused variables
jankaifer Feb 15, 2023
a6330b6
wip
jankaifer Feb 15, 2023
0cadaef
checkout code
jankaifer Feb 15, 2023
2c0e5a6
wip
jankaifer Feb 15, 2023
dbb865c
mov install to actin itself
jankaifer Feb 15, 2023
8a869c0
fix setup node step
jankaifer Feb 15, 2023
92b045f
added build step
jankaifer Feb 15, 2023
8d39fbc
Enable test for all examples
jankaifer Feb 15, 2023
494d995
increase timeout
jankaifer Feb 16, 2023
9a17e92
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Feb 16, 2023
b35c256
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Feb 17, 2023
eed8fb8
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Feb 23, 2023
bad9f53
refactor to use describe.each
jankaifer Feb 27, 2023
e2f938d
remove needles function
jankaifer Feb 27, 2023
006cb1c
Merge branch 'canary' into jankaifer/next-333-cover-examples-of-inter…
jankaifer Feb 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions examples/using-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
},
"dependencies": {
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "latest",
"react-dom": "latest",
"typescript": "latest",
"@types/react": "latest",
"@types/node": "latest"
}
}
12 changes: 6 additions & 6 deletions examples/with-typescript-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
},
"dependencies": {
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"@types/node": "^12.12.21",
"@types/react": "^16.9.16",
"@types/react-dom": "^16.9.4",
"typescript": "4.0"
"@types/node": "latest",
"@types/react": "latest",
"@types/react-dom": "latest",
"typescript": "4.9.4"
}
}
4 changes: 2 additions & 2 deletions examples/with-web-worker/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export default function Index() {
workerRef.current.onmessage = (event: MessageEvent<number>) =>
alert(`WebWorker Response => ${event.data}`)
return () => {
workerRef.current.terminate()
workerRef.current?.terminate()
}
}, [])

const handleWork = useCallback(async () => {
workerRef.current.postMessage(100000)
workerRef.current?.postMessage(100000)
}, [])

return (
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/examples/batch0.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { getExamplesBatch } from './getExamples'
import { testExample } from './testExample'

getExamplesBatch(0).forEach(testExample)
4 changes: 4 additions & 0 deletions test/e2e/examples/batch1.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { getExamplesBatch } from './getExamples'
import { testExample } from './testExample'

getExamplesBatch(1).forEach(testExample)
4 changes: 4 additions & 0 deletions test/e2e/examples/batch2.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { getExamplesBatch } from './getExamples'
import { testExample } from './testExample'

getExamplesBatch(2).forEach(testExample)
4 changes: 4 additions & 0 deletions test/e2e/examples/batch3.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { getExamplesBatch } from './getExamples'
import { testExample } from './testExample'

getExamplesBatch(3).forEach(testExample)
4 changes: 4 additions & 0 deletions test/e2e/examples/batch4.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { getExamplesBatch } from './getExamples'
import { testExample } from './testExample'

getExamplesBatch(4).forEach(testExample)
82 changes: 82 additions & 0 deletions test/e2e/examples/getExamples.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
const testedExamples = [
// Internal features
'active-class-name',
'amp',
'amp-first',
'amp-story',
'api-routes',
'api-routes-cors',
'api-routes-middleware',
'api-routes-rate-limit',
'api-routes-rest',
'app-dir-i18n-routing',
'app-dir-mdx',
'basic-css',
'basic-export',
'blog',
'blog-starter',
'catch-all-routes',
'custom-routes-proxying',
'custom-server',
'data-fetch',
'dynamic-routing',
'environment-variables',
'fast-refresh-demo',
'head-elements',
'headers',
'hello-world',
'hello-world-esm',
'i18n-routing',
'image-component',
'image-legacy-component',
'layout-component',
'middleware',
'middleware-matcher',
'modularize-imports',
'nested-components',
'next-css',
'next-forms',
'progressive-render',
'redirects',
'remove-console',
'reproduction-template',
'rewrites',
'script-component',
'ssr-caching',
'styled-jsx-with-csp',
'svg-components',
'using-router',
'with-absolute-imports',
'with-app-layout',
'with-context-api',
'with-env-from-next-config-js',
'with-loading',
'with-shallow-routing',
'with-sitemap',
'with-typescript',
'with-typescript-types',
'with-web-worker',
'with-webassembly',

// Library integrations that we can't break
'with-jest',
'with-jest-babel',
'with-mdx',
'with-mdx-remote',
'with-tailwindcss',
'with-turbopack',
'with-vercel-fetch',
// TODO: remove slice()
// We can't add all of them at once because the CI will timeout (because it will add all examples into one action)
].slice(0, 20)

const batches = 5
const batchSize = Math.floor((testedExamples.length + batches - 1) / batches)
/**
* We need to split examples into multiple files because otherwise our --timings magic won't be able to splid our tests into mulpitle actions
*/
export const getExamplesBatch = (n: number) =>
testedExamples.slice(
n * batchSize,
Math.min(testedExamples.length, (n + 1) * batchSize)
)
44 changes: 44 additions & 0 deletions test/e2e/examples/testExample.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { createNextDescribe } from 'e2e-utils'
import path from 'path'
import fs from 'fs-extra'

export const testExample = (example) => {
const exampleFiles = path.join(
__dirname,
'..',
'..',
'..',
'examples',
example
)

const packageJson = fs.readJsonSync(path.join(exampleFiles, 'package.json'))
describe(`example '${example}'`, () => {
// If there is an issue during a build, jest won't tell us which example caused it
// we need to log it ourselfs
beforeAll(() => {
require('console').log(`Running example '${example}'`)
})
createNextDescribe(
`example '${example}'`,
{
files: exampleFiles,
dependencies: {
// We need to make sure that these default dependencies are not installed by default
// for our examples to ensure that they have all their dependencies in package.json
'@types/node': undefined,
'@types/react': undefined,
next: undefined,
react: undefined,
'react-dom': undefined,
typescript: undefined,
...packageJson.dependencies,
...packageJson.devDependencies,
},
},
() => {
it('builds', () => {})
}
)
})
}