Unverified Commit 014a2549 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[test] Move all files to .ts (5/6) (#85640)

parent 15d0fd47
...@@ -791,7 +791,7 @@ jobs: ...@@ -791,7 +791,7 @@ jobs:
--concurrency 4 \ --concurrency 4 \
test/production/pages-dir/production/test/index.test.ts \ test/production/pages-dir/production/test/index.test.ts \
test/integration/css-client-nav/test/index.test.ts \ test/integration/css-client-nav/test/index.test.ts \
test/integration/rewrites-has-condition/test/index.test.js \ test/integration/rewrites-has-condition/test/index.test.ts \
test/integration/create-next-app/index.test.ts \ test/integration/create-next-app/index.test.ts \
test/integration/create-next-app/package-manager/pnpm.test.ts test/integration/create-next-app/package-manager/pnpm.test.ts
stepName: 'test-integration-windows' stepName: 'test-integration-windows'
......
...@@ -41,11 +41,11 @@ describe('Read-only source HMR', () => { ...@@ -41,11 +41,11 @@ describe('Read-only source HMR', () => {
appPort = await findPort() appPort = await findPort()
app = await launchApp(appDir, appPort, { app = await launchApp(appDir, appPort, {
env: { env: {
__NEXT_TEST_WITH_DEVTOOL: 1, __NEXT_TEST_WITH_DEVTOOL: '1',
// Events can be finicky in CI. This switches to a more reliable // Events can be finicky in CI. This switches to a more reliable
// polling method. // polling method.
CHOKIDAR_USEPOLLING: 'true', CHOKIDAR_USEPOLLING: 'true',
CHOKIDAR_INTERVAL: 500, CHOKIDAR_INTERVAL: '500',
}, },
}) })
}) })
......
...@@ -412,7 +412,7 @@ function runTests({ isDev = false, isExport = false, isPages404 = false }) { ...@@ -412,7 +412,7 @@ function runTests({ isDev = false, isExport = false, isPages404 = false }) {
describe('404 handling', () => { describe('404 handling', () => {
let nextOpts = {} let nextOpts = {}
beforeAll(async () => { beforeAll(async () => {
const hasLocalNext = await fs.exists(join(appDir, 'node_modules/next')) const hasLocalNext = fs.existsSync(join(appDir, 'node_modules/next'))
if (hasLocalNext) { if (hasLocalNext) {
nextOpts = { nextOpts = {
......
...@@ -77,10 +77,10 @@ describe('Required Server Files', () => { ...@@ -77,10 +77,10 @@ describe('Required Server Files', () => {
for (const file of requiredFilesManifest.files) { for (const file of requiredFilesManifest.files) {
console.log('checking', file) console.log('checking', file)
expect(await fs.exists(join(appDir, file))).toBe(true) expect(fs.existsSync(join(appDir, file))).toBe(true)
} }
expect(await fs.exists(join(appDir, '.next/server'))).toBe(true) expect(fs.existsSync(join(appDir, '.next/server'))).toBe(true)
}) })
it('should render SSR page correctly', async () => { it('should render SSR page correctly', async () => {
......
...@@ -44,7 +44,7 @@ describe('next/dynamic', () => { ...@@ -44,7 +44,7 @@ describe('next/dynamic', () => {
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests(true) runTests()
} }
) )
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
......
...@@ -33,17 +33,17 @@ const runTests = () => { ...@@ -33,17 +33,17 @@ const runTests = () => {
expect(scrollX).not.toBe(0) expect(scrollX).not.toBe(0)
expect(scrollY).not.toBe(0) expect(scrollY).not.toBe(0)
await browser.eval(() => window.next.router.push('/another')) await browser.eval(() => (window as any).next.router.push('/another'))
await retry(async () => { await retry(async () => {
const html = await browser.eval(() => document.documentElement.innerHTML) const html = await browser.eval(() => document.documentElement.innerHTML)
expect(html).toMatch(/hi from another/) expect(html).toMatch(/hi from another/)
}) })
await browser.eval(() => (window.didHydrate = false)) await browser.eval(() => ((window as any).didHydrate = false))
await browser.eval(() => window.history.back()) await browser.eval(() => window.history.back())
await retry(async () => { await retry(async () => {
expect(await browser.eval(() => window.didHydrate)).toBe(true) expect(await browser.eval(() => (window as any).didHydrate)).toBe(true)
}) })
const newScrollX = Math.floor(await browser.eval(() => window.scrollX)) const newScrollX = Math.floor(await browser.eval(() => window.scrollX))
......
...@@ -47,14 +47,10 @@ const runTests = () => { ...@@ -47,14 +47,10 @@ const runTests = () => {
/hi from another/ /hi from another/
) )
await browser.eval(() => (window.didHydrate = false)) await browser.eval(() => ((window as any).didHydrate = false))
await browser.eval(() => window.history.forward()) await browser.eval(() => window.history.forward())
await check(() => browser.eval(() => window.didHydrate), { await check(() => browser.eval(() => (window as any).didHydrate), true)
test(content) {
return content
},
})
const newScrollX = Math.floor(await browser.eval(() => window.scrollX)) const newScrollX = Math.floor(await browser.eval(() => window.scrollX))
const newScrollY = Math.floor(await browser.eval(() => window.scrollY)) const newScrollY = Math.floor(await browser.eval(() => window.scrollY))
......
...@@ -14,7 +14,7 @@ let app ...@@ -14,7 +14,7 @@ let app
let appPort let appPort
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
function runTests(dev) { function runTests(dev: boolean) {
it('should render from pages', async () => { it('should render from pages', async () => {
const html = await renderViaHTTP(appPort, '/') const html = await renderViaHTTP(appPort, '/')
expect(html).toMatch(/PAGES/) expect(html).toMatch(/PAGES/)
...@@ -50,7 +50,7 @@ describe('Dynamic Routing', () => { ...@@ -50,7 +50,7 @@ describe('Dynamic Routing', () => {
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests() runTests(false)
} }
) )
}) })
...@@ -85,7 +85,7 @@ describe('Dynamic Routing', () => { ...@@ -85,7 +85,7 @@ describe('Dynamic Routing', () => {
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests(true) runTests()
} }
) )
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
......
...@@ -78,7 +78,7 @@ describe('SSG data 404', () => { ...@@ -78,7 +78,7 @@ describe('SSG data 404', () => {
proxy.web(req, res) proxy.web(req, res)
}) })
await new Promise((resolve) => { await new Promise<void>((resolve) => {
proxyServer.listen(proxyPort, () => resolve()) proxyServer.listen(proxyPort, () => resolve())
}) })
}) })
...@@ -120,7 +120,7 @@ describe('SSG data 404', () => { ...@@ -120,7 +120,7 @@ describe('SSG data 404', () => {
}) })
}) })
await new Promise((resolve) => { await new Promise<void>((resolve) => {
proxyServer.listen(proxyPort, () => resolve()) proxyServer.listen(proxyPort, () => resolve())
}) })
}) })
......
...@@ -42,7 +42,7 @@ describe('Custom 404 Page for static site generation with dynamic routes', () => ...@@ -42,7 +42,7 @@ describe('Custom 404 Page for static site generation with dynamic routes', () =>
app = await nextStart(appDir, appPort) app = await nextStart(appDir, appPort)
}) })
runTests('server') runTests()
} }
) )
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
...@@ -54,7 +54,7 @@ describe('Custom 404 Page for static site generation with dynamic routes', () => ...@@ -54,7 +54,7 @@ describe('Custom 404 Page for static site generation with dynamic routes', () =>
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests('dev') runTests()
} }
) )
}) })
...@@ -23,7 +23,7 @@ describe('config telemetry', () => { ...@@ -23,7 +23,7 @@ describe('config telemetry', () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.rename( await fs.rename(
...@@ -53,7 +53,7 @@ describe('config telemetry', () => { ...@@ -53,7 +53,7 @@ describe('config telemetry', () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.rename( await fs.rename(
...@@ -101,7 +101,7 @@ describe('config telemetry', () => { ...@@ -101,7 +101,7 @@ describe('config telemetry', () => {
stderr2 += msg || '' stderr2 += msg || ''
}, },
env: { env: {
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
}) })
await check(() => stderr2, /NEXT_CLI_SESSION_STARTED/) await check(() => stderr2, /NEXT_CLI_SESSION_STARTED/)
...@@ -142,7 +142,7 @@ describe('config telemetry', () => { ...@@ -142,7 +142,7 @@ describe('config telemetry', () => {
try { try {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
try { try {
...@@ -166,7 +166,7 @@ describe('config telemetry', () => { ...@@ -166,7 +166,7 @@ describe('config telemetry', () => {
async () => { async () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
const featureUsageEvents = findAllTelemetryEvents( const featureUsageEvents = findAllTelemetryEvents(
stderr, stderr,
...@@ -210,7 +210,7 @@ describe('config telemetry', () => { ...@@ -210,7 +210,7 @@ describe('config telemetry', () => {
) )
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.rename( await fs.rename(
path.join(appDir, 'next.config.js'), path.join(appDir, 'next.config.js'),
...@@ -268,7 +268,7 @@ describe('config telemetry', () => { ...@@ -268,7 +268,7 @@ describe('config telemetry', () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.rename( await fs.rename(
...@@ -294,7 +294,7 @@ describe('config telemetry', () => { ...@@ -294,7 +294,7 @@ describe('config telemetry', () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.rename( await fs.rename(
...@@ -320,7 +320,7 @@ describe('config telemetry', () => { ...@@ -320,7 +320,7 @@ describe('config telemetry', () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.rename( await fs.rename(
...@@ -346,7 +346,7 @@ describe('config telemetry', () => { ...@@ -346,7 +346,7 @@ describe('config telemetry', () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.remove(path.join(appDir, 'middleware.js')) await fs.remove(path.join(appDir, 'middleware.js'))
...@@ -378,7 +378,7 @@ describe('config telemetry', () => { ...@@ -378,7 +378,7 @@ describe('config telemetry', () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.rename( await fs.rename(
...@@ -416,7 +416,7 @@ describe('config telemetry', () => { ...@@ -416,7 +416,7 @@ describe('config telemetry', () => {
async () => { async () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
const featureUsageEvents = findAllTelemetryEvents( const featureUsageEvents = findAllTelemetryEvents(
stderr, stderr,
...@@ -443,7 +443,7 @@ describe('config telemetry', () => { ...@@ -443,7 +443,7 @@ describe('config telemetry', () => {
async () => { async () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
const featureUsageEvents = findAllTelemetryEvents( const featureUsageEvents = findAllTelemetryEvents(
stderr, stderr,
...@@ -468,7 +468,7 @@ describe('config telemetry', () => { ...@@ -468,7 +468,7 @@ describe('config telemetry', () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.rename( await fs.rename(
...@@ -499,7 +499,7 @@ describe('config telemetry', () => { ...@@ -499,7 +499,7 @@ describe('config telemetry', () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.rename( await fs.rename(
...@@ -527,7 +527,7 @@ describe('config telemetry', () => { ...@@ -527,7 +527,7 @@ describe('config telemetry', () => {
it('emits telemetry for default React Compiler options', async () => { it('emits telemetry for default React Compiler options', async () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
try { try {
...@@ -554,7 +554,7 @@ describe('config telemetry', () => { ...@@ -554,7 +554,7 @@ describe('config telemetry', () => {
try { try {
const app = await nextBuild(appDir, [], { const app = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
stderr = app.stderr stderr = app.stderr
const event = /NEXT_CLI_SESSION_STARTED[\s\S]+?{([\s\S]+?)}/ const event = /NEXT_CLI_SESSION_STARTED[\s\S]+?{([\s\S]+?)}/
...@@ -585,7 +585,7 @@ describe('config telemetry', () => { ...@@ -585,7 +585,7 @@ describe('config telemetry', () => {
try { try {
const app = await nextBuild(appDir, [], { const app = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
stderr = app.stderr stderr = app.stderr
const event = /NEXT_CLI_SESSION_STARTED[\s\S]+?{([\s\S]+?)}/ const event = /NEXT_CLI_SESSION_STARTED[\s\S]+?{([\s\S]+?)}/
...@@ -623,7 +623,7 @@ describe('config telemetry', () => { ...@@ -623,7 +623,7 @@ describe('config telemetry', () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.rename( await fs.rename(
...@@ -662,7 +662,7 @@ describe('config telemetry', () => { ...@@ -662,7 +662,7 @@ describe('config telemetry', () => {
try { try {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
try { try {
...@@ -697,7 +697,7 @@ describe('config telemetry', () => { ...@@ -697,7 +697,7 @@ describe('config telemetry', () => {
try { try {
app = await launchApp(appDir, await findPort(), { app = await launchApp(appDir, await findPort(), {
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
onStderr(msg) { onStderr(msg) {
stderr += msg || '' stderr += msg || ''
}, },
...@@ -733,7 +733,7 @@ describe('config telemetry', () => { ...@@ -733,7 +733,7 @@ describe('config telemetry', () => {
try { try {
const app = await nextBuild(appDir, [], { const app = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
stderr = app.stderr stderr = app.stderr
...@@ -761,7 +761,7 @@ describe('config telemetry', () => { ...@@ -761,7 +761,7 @@ describe('config telemetry', () => {
try { try {
const app = await nextBuild(appDir, [], { const app = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
stderr = app.stderr stderr = app.stderr
......
...@@ -105,7 +105,7 @@ describe('Telemetry CLI', () => { ...@@ -105,7 +105,7 @@ describe('Telemetry CLI', () => {
env: { env: {
// block swc from loading // block swc from loading
NODE_OPTIONS: '--no-addons', NODE_OPTIONS: '--no-addons',
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
}) })
expect(stderr).toMatch(/NEXT_SWC_LOAD_FAILURE/) expect(stderr).toMatch(/NEXT_SWC_LOAD_FAILURE/)
...@@ -125,7 +125,7 @@ describe('Telemetry CLI', () => { ...@@ -125,7 +125,7 @@ describe('Telemetry CLI', () => {
const { stderr } = await runNextCommand(['build', appDir], { const { stderr } = await runNextCommand(['build', appDir], {
stderr: true, stderr: true,
env: { env: {
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
}) })
await fs.rename( await fs.rename(
...@@ -148,7 +148,7 @@ describe('Telemetry CLI', () => { ...@@ -148,7 +148,7 @@ describe('Telemetry CLI', () => {
const { stderr } = await runNextCommand(['build', appDir], { const { stderr } = await runNextCommand(['build', appDir], {
stderr: true, stderr: true,
env: { env: {
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
}) })
await fs.rename( await fs.rename(
...@@ -173,7 +173,7 @@ describe('Telemetry CLI', () => { ...@@ -173,7 +173,7 @@ describe('Telemetry CLI', () => {
const { stderr } = await runNextCommand(['build', appDir], { const { stderr } = await runNextCommand(['build', appDir], {
stderr: true, stderr: true,
env: { env: {
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
}) })
...@@ -195,7 +195,7 @@ describe('Telemetry CLI', () => { ...@@ -195,7 +195,7 @@ describe('Telemetry CLI', () => {
const { stderr } = await runNextCommand(['build', appDir], { const { stderr } = await runNextCommand(['build', appDir], {
stderr: true, stderr: true,
env: { env: {
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
}) })
await fs.rename( await fs.rename(
...@@ -221,7 +221,7 @@ describe('Telemetry CLI', () => { ...@@ -221,7 +221,7 @@ describe('Telemetry CLI', () => {
const { stderr } = await runNextCommand(['build', appDir], { const { stderr } = await runNextCommand(['build', appDir], {
stderr: true, stderr: true,
env: { env: {
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
}) })
await fs.rename( await fs.rename(
...@@ -247,7 +247,7 @@ describe('Telemetry CLI', () => { ...@@ -247,7 +247,7 @@ describe('Telemetry CLI', () => {
const { stderr } = await runNextCommand(['build', appDir], { const { stderr } = await runNextCommand(['build', appDir], {
stderr: true, stderr: true,
env: { env: {
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
}) })
await fs.rename( await fs.rename(
...@@ -273,7 +273,7 @@ describe('Telemetry CLI', () => { ...@@ -273,7 +273,7 @@ describe('Telemetry CLI', () => {
const { stderr } = await runNextCommand(['build', appDir], { const { stderr } = await runNextCommand(['build', appDir], {
stderr: true, stderr: true,
env: { env: {
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
}) })
await fs.rename( await fs.rename(
...@@ -299,7 +299,7 @@ describe('Telemetry CLI', () => { ...@@ -299,7 +299,7 @@ describe('Telemetry CLI', () => {
const { stderr } = await runNextCommand(['build', appDir], { const { stderr } = await runNextCommand(['build', appDir], {
stderr: true, stderr: true,
env: { env: {
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
}) })
await fs.rename( await fs.rename(
...@@ -337,7 +337,7 @@ describe('Telemetry CLI', () => { ...@@ -337,7 +337,7 @@ describe('Telemetry CLI', () => {
it('detect static 404 correctly for `next build`', async () => { it('detect static 404 correctly for `next build`', async () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
const event1 = /NEXT_BUILD_OPTIMIZED[\s\S]+?{([\s\S]+?)}/ const event1 = /NEXT_BUILD_OPTIMIZED[\s\S]+?{([\s\S]+?)}/
...@@ -349,7 +349,7 @@ describe('Telemetry CLI', () => { ...@@ -349,7 +349,7 @@ describe('Telemetry CLI', () => {
it('detect page counts correctly for `next build`', async () => { it('detect page counts correctly for `next build`', async () => {
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
const event1 = /NEXT_BUILD_OPTIMIZED[\s\S]+?{([\s\S]+?)}/ const event1 = /NEXT_BUILD_OPTIMIZED[\s\S]+?{([\s\S]+?)}/
......
...@@ -23,7 +23,7 @@ describe('page features telemetry', () => { ...@@ -23,7 +23,7 @@ describe('page features telemetry', () => {
let app = await launchApp(appDir, port, { let app = await launchApp(appDir, port, {
onStderr: handleStderr, onStderr: handleStderr,
env: { env: {
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
turbo: true, turbo: true,
}) })
...@@ -58,7 +58,7 @@ describe('page features telemetry', () => { ...@@ -58,7 +58,7 @@ describe('page features telemetry', () => {
let app = await launchApp(appDir, port, { let app = await launchApp(appDir, port, {
onStderr: handleStderr, onStderr: handleStderr,
env: { env: {
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
turbo: true, turbo: true,
}) })
...@@ -94,7 +94,7 @@ describe('page features telemetry', () => { ...@@ -94,7 +94,7 @@ describe('page features telemetry', () => {
let app = await launchApp(appDir, port, { let app = await launchApp(appDir, port, {
onStderr: handleStderr, onStderr: handleStderr,
env: { env: {
NEXT_TELEMETRY_DEBUG: 1, NEXT_TELEMETRY_DEBUG: '1',
}, },
}) })
...@@ -163,7 +163,7 @@ describe('page features telemetry', () => { ...@@ -163,7 +163,7 @@ describe('page features telemetry', () => {
) )
const { stderr } = await nextBuild(appDir, [], { const { stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
try { try {
...@@ -198,7 +198,7 @@ describe('page features telemetry', () => { ...@@ -198,7 +198,7 @@ describe('page features telemetry', () => {
let build = await nextBuild(appDir, [], { let build = await nextBuild(appDir, [], {
stderr: 'log', stderr: 'log',
stdout: 'log', stdout: 'log',
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
expect(build.stderr).toContain('NEXT_BUILD_OPTIMIZED') expect(build.stderr).toContain('NEXT_BUILD_OPTIMIZED')
...@@ -222,7 +222,7 @@ describe('page features telemetry', () => { ...@@ -222,7 +222,7 @@ describe('page features telemetry', () => {
const build = await nextBuild(appDir, [], { const build = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.rename( await fs.rename(
...@@ -256,7 +256,7 @@ describe('page features telemetry', () => { ...@@ -256,7 +256,7 @@ describe('page features telemetry', () => {
const build = await nextBuild(appDir, [], { const build = await nextBuild(appDir, [], {
stderr: true, stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 }, env: { NEXT_TELEMETRY_DEBUG: '1' },
}) })
await fs.rename( await fs.rename(
......
...@@ -15,7 +15,7 @@ let app ...@@ -15,7 +15,7 @@ let app
let appPort let appPort
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
const runTests = (dev) => { const runTests = (dev: boolean) => {
it('should route to /blog/another/ correctly', async () => { it('should route to /blog/another/ correctly', async () => {
const browser = await webdriver(appPort, '/') const browser = await webdriver(appPort, '/')
await browser.elementByCss('#to-blog-another').click() await browser.elementByCss('#to-blog-another').click()
...@@ -115,7 +115,7 @@ describe('href resolving trailing-slash', () => { ...@@ -115,7 +115,7 @@ describe('href resolving trailing-slash', () => {
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests() runTests(false)
} }
) )
}) })
/* eslint-env jest */ /* eslint-env jest */
import { createFile, exists, readFile, writeFile, remove } from 'fs-extra' import { createFile, existsSync, readFile, writeFile, remove } from 'fs-extra'
import { nextBuild } from 'next-test-utils' import { nextBuild } from 'next-test-utils'
import path from 'path' import path from 'path'
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
...@@ -21,7 +21,7 @@ import path from 'path' ...@@ -21,7 +21,7 @@ import path from 'path'
}) })
it('Creates a default tsconfig.json when one is missing', async () => { it('Creates a default tsconfig.json when one is missing', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
const { code } = await nextBuild(appDir) const { code } = await nextBuild(appDir)
expect(code).toBe(0) expect(code).toBe(0)
expect(await readFile(tsConfig, 'utf8')).toMatchInlineSnapshot(` expect(await readFile(tsConfig, 'utf8')).toMatchInlineSnapshot(`
...@@ -68,7 +68,7 @@ import path from 'path' ...@@ -68,7 +68,7 @@ import path from 'path'
}) })
it('Works with an empty tsconfig.json (docs)', async () => { it('Works with an empty tsconfig.json (docs)', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
await createFile(tsConfig) await createFile(tsConfig)
await new Promise((resolve) => setTimeout(resolve, 500)) await new Promise((resolve) => setTimeout(resolve, 500))
...@@ -125,7 +125,7 @@ import path from 'path' ...@@ -125,7 +125,7 @@ import path from 'path'
}) })
it('Updates an existing tsconfig.json without losing comments', async () => { it('Updates an existing tsconfig.json without losing comments', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
await writeFile( await writeFile(
tsConfig, tsConfig,
...@@ -202,7 +202,7 @@ import path from 'path' ...@@ -202,7 +202,7 @@ import path from 'path'
}) })
it('allows you to set commonjs module mode', async () => { it('allows you to set commonjs module mode', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
await writeFile( await writeFile(
tsConfig, tsConfig,
...@@ -256,7 +256,7 @@ import path from 'path' ...@@ -256,7 +256,7 @@ import path from 'path'
}) })
it('allows you to set es2020 module mode', async () => { it('allows you to set es2020 module mode', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
await writeFile( await writeFile(
tsConfig, tsConfig,
...@@ -310,7 +310,7 @@ import path from 'path' ...@@ -310,7 +310,7 @@ import path from 'path'
}) })
it('allows you to set node16 moduleResolution mode', async () => { it('allows you to set node16 moduleResolution mode', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
await writeFile( await writeFile(
tsConfig, tsConfig,
...@@ -368,7 +368,7 @@ import path from 'path' ...@@ -368,7 +368,7 @@ import path from 'path'
}) })
it('allows you to set bundler moduleResolution mode', async () => { it('allows you to set bundler moduleResolution mode', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
await writeFile( await writeFile(
tsConfig, tsConfig,
...@@ -426,7 +426,7 @@ import path from 'path' ...@@ -426,7 +426,7 @@ import path from 'path'
}) })
it('allows you to set target mode', async () => { it('allows you to set target mode', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
await writeFile(tsConfig, `{ "compilerOptions": { "target": "es2022" } }`) await writeFile(tsConfig, `{ "compilerOptions": { "target": "es2022" } }`)
await new Promise((resolve) => setTimeout(resolve, 500)) await new Promise((resolve) => setTimeout(resolve, 500))
...@@ -481,7 +481,7 @@ import path from 'path' ...@@ -481,7 +481,7 @@ import path from 'path'
}) })
it('allows you to set node16 module mode', async () => { it('allows you to set node16 module mode', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
await writeFile( await writeFile(
tsConfig, tsConfig,
...@@ -539,7 +539,7 @@ import path from 'path' ...@@ -539,7 +539,7 @@ import path from 'path'
}) })
it('allows you to set verbatimModuleSyntax true without adding isolatedModules', async () => { it('allows you to set verbatimModuleSyntax true without adding isolatedModules', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
await writeFile( await writeFile(
tsConfig, tsConfig,
...@@ -597,8 +597,8 @@ import path from 'path' ...@@ -597,8 +597,8 @@ import path from 'path'
}) })
it('allows you to set verbatimModuleSyntax true via extends without adding isolatedModules', async () => { it('allows you to set verbatimModuleSyntax true via extends without adding isolatedModules', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
expect(await exists(tsConfigBase)).toBe(false) expect(existsSync(tsConfigBase)).toBe(false)
await writeFile( await writeFile(
tsConfigBase, tsConfigBase,
...@@ -655,8 +655,8 @@ import path from 'path' ...@@ -655,8 +655,8 @@ import path from 'path'
}) })
it('allows you to extend another configuration file', async () => { it('allows you to extend another configuration file', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
expect(await exists(tsConfigBase)).toBe(false) expect(existsSync(tsConfigBase)).toBe(false)
await writeFile( await writeFile(
tsConfigBase, tsConfigBase,
...@@ -718,8 +718,8 @@ import path from 'path' ...@@ -718,8 +718,8 @@ import path from 'path'
}) })
it('creates compilerOptions when you extend another config', async () => { it('creates compilerOptions when you extend another config', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
expect(await exists(tsConfigBase)).toBe(false) expect(existsSync(tsConfigBase)).toBe(false)
await writeFile( await writeFile(
tsConfigBase, tsConfigBase,
...@@ -781,7 +781,7 @@ import path from 'path' ...@@ -781,7 +781,7 @@ import path from 'path'
// TODO: Enable this test when repo has upgraded to TypeScript 5.4. Currently tested as E2E: tsconfig-module-preserve // TODO: Enable this test when repo has upgraded to TypeScript 5.4. Currently tested as E2E: tsconfig-module-preserve
it.skip('allows you to skip moduleResolution, esModuleInterop and resolveJsonModule when using "module: preserve"', async () => { it.skip('allows you to skip moduleResolution, esModuleInterop and resolveJsonModule when using "module: preserve"', async () => {
expect(await exists(tsConfig)).toBe(false) expect(existsSync(tsConfig)).toBe(false)
await writeFile( await writeFile(
tsConfig, tsConfig,
......
...@@ -13,10 +13,7 @@ describe('typeof window replace', () => { ...@@ -13,10 +13,7 @@ describe('typeof window replace', () => {
() => { () => {
beforeAll(async () => { beforeAll(async () => {
await nextBuild(appDir) await nextBuild(appDir)
buildManifest = require(path.join( buildManifest = require(path.join(appDir, '.next/build-manifest.json'))
appDir,
'.next/build-manifest.json'
), 'utf8')
}) })
it('Replaces `typeof window` with object for client code', async () => { it('Replaces `typeof window` with object for client code', async () => {
...@@ -40,6 +37,7 @@ describe('typeof window replace', () => { ...@@ -40,6 +37,7 @@ describe('typeof window replace', () => {
const allFilesInDotNextServerChunks = await fs const allFilesInDotNextServerChunks = await fs
.readdirSync(chunksFilesDir, { .readdirSync(chunksFilesDir, {
recursive: true, recursive: true,
encoding: 'utf-8',
}) })
.filter((item) => item.endsWith('.js')) .filter((item) => item.endsWith('.js'))
for (const file of allFilesInDotNextServerChunks) { for (const file of allFilesInDotNextServerChunks) {
...@@ -54,6 +52,7 @@ describe('typeof window replace', () => { ...@@ -54,6 +52,7 @@ describe('typeof window replace', () => {
const allFilesInDotNextServerPages = await fs const allFilesInDotNextServerPages = await fs
.readdirSync(pagesFilesDir, { .readdirSync(pagesFilesDir, {
recursive: true, recursive: true,
encoding: 'utf-8',
}) })
.filter((item) => item.endsWith('.js')) .filter((item) => item.endsWith('.js'))
for (const file of allFilesInDotNextServerPages) { for (const file of allFilesInDotNextServerPages) {
......
...@@ -8,7 +8,7 @@ const appDir = join(__dirname, '..') ...@@ -8,7 +8,7 @@ const appDir = join(__dirname, '..')
let appPort let appPort
let app let app
async function get$(path, query) { async function get$(path, query?: any) {
const html = await renderViaHTTP(appPort, path, query) const html = await renderViaHTTP(appPort, path, query)
return cheerio.load(html) return cheerio.load(html)
} }
......
...@@ -8,7 +8,7 @@ const appDir = join(__dirname, '..') ...@@ -8,7 +8,7 @@ const appDir = join(__dirname, '..')
let appPort let appPort
let app let app
async function get$(path, query) { async function get$(path, query?: any) {
const html = await renderViaHTTP(appPort, path, query) const html = await renderViaHTTP(appPort, path, query)
return cheerio.load(html) return cheerio.load(html)
} }
......
...@@ -21,7 +21,7 @@ const handleOutput = (msg) => { ...@@ -21,7 +21,7 @@ const handleOutput = (msg) => {
output += msg output += msg
} }
async function get$(path, query, options) { async function get$(path, query?: any, options?: any) {
const html = await renderViaHTTP(appPort, path, query, options) const html = await renderViaHTTP(appPort, path, query, options)
return cheerio.load(html) return cheerio.load(html)
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment