rsnext/test/development/basic/project-directory-rename.test.ts
JJ Kasper 29c2e89bd1
Break up large test suites (#50458)
This breaks up some of our longest running tests which allows more
parallelizing of the tests. This also moves turbopack tests filtering
back to an allow list as it is running a lot of unrelated tests
currently which isn't ideal. We should only be running against tests
that are explicitly testing turbopack e.g. build tests should not be
duplicated in the turbopack group.

```sh
test/integration/css/test/group-1.test.js: 762.655
test/integration/edge-runtime-module-errors/test/index.test.js: 695.309
test/integration/css/test/group-2.test.js: 671.848
test/integration/i18n-support/test/index.test.js: 518.173
test/integration/scss-modules/test/index.test.js: 451.704
test/integration/css-features/test/index.test.js: 417.318
test/integration/css-modules/test/index.test.js: 403.405
test/integration/eslint/test/index.test.js: 381.563
test/integration/500-page/test/index.test.js: 371.134
test/integration/telemetry/test/index.test.js: 367.691
test/development/acceptance-app/ReactRefreshLogBox.test.ts: 335.878
test/integration/create-next-app/templates.test.ts: 334.01
test/integration/scss/test/group-2.test.js: 327.255
test/integration/scss/test/group-1.test.js: 318.574
test/integration/edge-runtime-configurable-guards/test/index.test.js: 313.834
test/e2e/instrumentation-hook/instrumentation-hook.test.ts: 294.618
test/development/acceptance-app/error-recovery.test.ts: 283.355
test/e2e/app-dir/app/vercel-speed-insights.test.ts: 278.242
test/integration/create-next-app/index.test.ts: 272.442
```
2023-05-28 13:59:41 -07:00

70 lines
1.9 KiB
TypeScript

import fs from 'fs-extra'
import webdriver from 'next-webdriver'
import { check, findPort, hasRedbox } from 'next-test-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { createNext } from 'e2e-utils'
import stripAnsi from 'strip-ansi'
// TODO: investigate occasional failure
describe.skip('Project Directory Renaming', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
'pages/index.js': `
export default function Page() {
return <p>hello world</p>
}
`,
},
skipStart: true,
forcedPort: (await findPort()) + '',
})
await next.start()
})
afterAll(() => next.destroy().catch(() => {}))
it('should detect project dir rename and restart', async () => {
const browser = await webdriver(next.url, '/')
await browser.eval('window.beforeNav = 1')
let newTestDir = `${next.testDir}-renamed`
await fs.move(next.testDir, newTestDir)
next.testDir = newTestDir
await check(
() => stripAnsi(next.cliOutput),
/Detected project directory rename, restarting in new location/
)
await check(async () => {
return (await browser.eval('window.beforeNav')) === 1 ? 'pending' : 'done'
}, 'done')
expect(await hasRedbox(browser, false)).toBe(false)
try {
// should still HMR correctly
await next.patchFile(
'pages/index.js',
(
await next.readFile('pages/index.js')
).replace('hello world', 'hello again')
)
await check(async () => {
if (!(await browser.eval('!!window.next'))) {
await browser.refresh()
}
return browser.eval('document.documentElement.innerHTML')
}, /hello again/)
} finally {
await next.patchFile(
'pages/index.js',
(
await next.readFile('pages/index.js')
).replace('hello again', 'hello world')
)
}
})
})