Unverified Commit 1b87ebd4 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[test] Move all files to .ts (3/6) (#85638)

parent f811a6d5
...@@ -27,7 +27,7 @@ const runTests = () => { ...@@ -27,7 +27,7 @@ const runTests = () => {
it('should have correct fallback query (hydration)', async () => { it('should have correct fallback query (hydration)', async () => {
const browser = await webdriver(appPort, '/second') const browser = await webdriver(appPort, '/second')
const initialSlug = await browser.eval(() => window.initialSlug) const initialSlug = await browser.eval(() => (window as any).initialSlug)
expect(initialSlug).toBeFalsy() expect(initialSlug).toBeFalsy()
await browser.waitForElementByCss('#query') await browser.waitForElementByCss('#query')
......
...@@ -17,7 +17,7 @@ let app ...@@ -17,7 +17,7 @@ let app
let apiServerPort let apiServerPort
let apiServer let apiServer
const startApiServer = async (optEnv = {}, opts) => { const startApiServer = async (optEnv = {}, opts?: any) => {
const scriptPath = join(appDir, 'api-server.js') const scriptPath = join(appDir, 'api-server.js')
apiServerPort = await findPort() apiServerPort = await findPort()
const env = Object.assign( const env = Object.assign(
......
...@@ -19,7 +19,7 @@ let app ...@@ -19,7 +19,7 @@ let app
let apiServerPort let apiServerPort
let apiServer let apiServer
const startApiServer = async (optEnv = {}, opts) => { const startApiServer = async (optEnv = {}, opts?: any) => {
const scriptPath = join(appDir, 'api-server.js') const scriptPath = join(appDir, 'api-server.js')
apiServerPort = await findPort() apiServerPort = await findPort()
const env = Object.assign( const env = Object.assign(
......
...@@ -4482,7 +4482,7 @@ describe('File Serving', () => { ...@@ -4482,7 +4482,7 @@ describe('File Serving', () => {
await killApp(app) await killApp(app)
}) })
runTests(true) runTests()
} }
) )
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
......
...@@ -9,7 +9,7 @@ const appDir = join(__dirname, '../') ...@@ -9,7 +9,7 @@ const appDir = join(__dirname, '../')
let appPort let appPort
let server let server
const context = {} const context: Record<string, any> = {}
const startServer = async (optEnv = {}) => { const startServer = async (optEnv = {}) => {
const scriptPath = join(appDir, 'server.js') const scriptPath = join(appDir, 'server.js')
...@@ -23,7 +23,7 @@ describe('FileSystemPublicRoutes', () => { ...@@ -23,7 +23,7 @@ describe('FileSystemPublicRoutes', () => {
beforeAll(() => startServer()) beforeAll(() => startServer())
afterAll(() => killApp(server)) afterAll(() => killApp(server))
const fetch = (p, q) => fetchViaHTTP(context.appPort, p, q) const fetch = (p, q?: any) => fetchViaHTTP(context.appPort, p, q)
it('should not route to the index page', async () => { it('should not route to the index page', async () => {
const res = await fetch('/') const res = await fetch('/')
......
...@@ -74,7 +74,7 @@ function runTests(startServer = nextStart) { ...@@ -74,7 +74,7 @@ function runTests(startServer = nextStart) {
expect(res.status).toBe(200) expect(res.status).toBe(200)
const originalCookies = res.headers.get('set-cookie').split(',') const originalCookies = res.headers.get('set-cookie').split(',')
const cookies = originalCookies.map(cookie.parse) const cookies = originalCookies.map((rawCookie) => cookie.parse(rawCookie))
expect(originalCookies.every((c) => c.includes('; Secure;'))).toBe(true) expect(originalCookies.every((c) => c.includes('; Secure;'))).toBe(true)
...@@ -143,7 +143,7 @@ function runTests(startServer = nextStart) { ...@@ -143,7 +143,7 @@ function runTests(startServer = nextStart) {
.get('set-cookie') .get('set-cookie')
.replace(/(=(?!Lax)\w{3}),/g, '$1') .replace(/(=(?!Lax)\w{3}),/g, '$1')
.split(',') .split(',')
.map(cookie.parse) .map((rawCookie) => cookie.parse(rawCookie))
expect(cookies.length).toBe(2) expect(cookies.length).toBe(2)
expect(cookies[0]).toMatchObject({ expect(cookies[0]).toMatchObject({
...@@ -193,7 +193,7 @@ describe('ServerSide Props Preview Mode', () => { ...@@ -193,7 +193,7 @@ describe('ServerSide Props Preview Mode', () => {
const cookies = res.headers const cookies = res.headers
.get('set-cookie') .get('set-cookie')
.split(',') .split(',')
.map(cookie.parse) .map((rawCookie) => cookie.parse(rawCookie))
expect(cookies.length).toBe(2) expect(cookies.length).toBe(2)
previewCookieString = previewCookieString =
...@@ -231,7 +231,7 @@ describe('ServerSide Props Preview Mode', () => { ...@@ -231,7 +231,7 @@ describe('ServerSide Props Preview Mode', () => {
.get('set-cookie') .get('set-cookie')
.replace(/(=(?!Lax)\w{3}),/g, '$1') .replace(/(=(?!Lax)\w{3}),/g, '$1')
.split(',') .split(',')
.map(cookie.parse) .map((rawCookie) => cookie.parse(rawCookie))
expect(cookies.length).toBe(2) expect(cookies.length).toBe(2)
}) })
......
...@@ -20,7 +20,7 @@ let app ...@@ -20,7 +20,7 @@ let app
let appPort let appPort
let indexPageContent let indexPageContent
const runTests = (isDev) => { const runTests = (isDev: boolean) => {
const getData = async () => { const getData = async () => {
if (isDev) { if (isDev) {
appPort = await findPort() appPort = await findPort()
...@@ -96,7 +96,7 @@ describe('gip identifiers', () => { ...@@ -96,7 +96,7 @@ describe('gip identifiers', () => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode', 'production mode',
() => { () => {
runTests() runTests(false)
} }
) )
}) })
...@@ -20,7 +20,7 @@ let appPort ...@@ -20,7 +20,7 @@ let appPort
const basePath = '/docs' const basePath = '/docs'
const runTests = (isDev) => { const runTests = (isDev: boolean) => {
it('should apply temporary redirect when visited directly for GSSP page', async () => { it('should apply temporary redirect when visited directly for GSSP page', async () => {
const res = await fetchViaHTTP( const res = await fetchViaHTTP(
appPort, appPort,
...@@ -142,7 +142,7 @@ const runTests = (isDev) => { ...@@ -142,7 +142,7 @@ const runTests = (isDev) => {
post: 'first', post: 'first',
}, },
}) })
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
const { pathname } = url.parse(initialHref) const { pathname } = url.parse(initialHref)
expect(pathname).toBe(`${basePath}/gsp-blog/redirect-dest-_gsp-blog_first`) expect(pathname).toBe(`${basePath}/gsp-blog/redirect-dest-_gsp-blog_first`)
}) })
...@@ -165,7 +165,7 @@ const runTests = (isDev) => { ...@@ -165,7 +165,7 @@ const runTests = (isDev) => {
post: 'first', post: 'first',
}, },
}) })
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
const { pathname } = url.parse(initialHref) const { pathname } = url.parse(initialHref)
// since it was cached the initial value is now the redirect // since it was cached the initial value is now the redirect
// result // result
...@@ -184,7 +184,7 @@ const runTests = (isDev) => { ...@@ -184,7 +184,7 @@ const runTests = (isDev) => {
await browser.waitForElementByCss('#index') await browser.waitForElementByCss('#index')
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
const { pathname } = url.parse(initialHref) const { pathname } = url.parse(initialHref)
expect(pathname).toBe(`${basePath}/gsp-blog/redirect-dest-_`) expect(pathname).toBe(`${basePath}/gsp-blog/redirect-dest-_`)
}) })
...@@ -201,7 +201,7 @@ const runTests = (isDev) => { ...@@ -201,7 +201,7 @@ const runTests = (isDev) => {
await browser.waitForElementByCss('#index') await browser.waitForElementByCss('#index')
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
const { pathname } = url.parse(initialHref) const { pathname } = url.parse(initialHref)
expect(pathname).toBe(`${basePath}`) expect(pathname).toBe(`${basePath}`)
}) })
...@@ -221,7 +221,7 @@ const runTests = (isDev) => { ...@@ -221,7 +221,7 @@ const runTests = (isDev) => {
/oops not found/ /oops not found/
) )
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
expect(initialHref).toBeFalsy() expect(initialHref).toBeFalsy()
const curUrl = await browser.url() const curUrl = await browser.url()
...@@ -243,7 +243,7 @@ const runTests = (isDev) => { ...@@ -243,7 +243,7 @@ const runTests = (isDev) => {
'example.vercel.sh' 'example.vercel.sh'
) )
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
expect(initialHref).toBeFalsy() expect(initialHref).toBeFalsy()
}) })
...@@ -261,7 +261,7 @@ const runTests = (isDev) => { ...@@ -261,7 +261,7 @@ const runTests = (isDev) => {
'example.vercel.sh' 'example.vercel.sh'
) )
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
expect(initialHref).toBeFalsy() expect(initialHref).toBeFalsy()
const res = await fetchViaHTTP( const res = await fetchViaHTTP(
...@@ -503,7 +503,7 @@ describe('GS(S)P Redirect Support', () => { ...@@ -503,7 +503,7 @@ describe('GS(S)P Redirect Support', () => {
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests() runTests(false)
it('should error for redirect during prerendering', async () => { it('should error for redirect during prerendering', async () => {
await fs.mkdirp(join(appDir, 'pages/invalid')) await fs.mkdirp(join(appDir, 'pages/invalid'))
......
...@@ -12,7 +12,7 @@ import webdriver from 'next-webdriver' ...@@ -12,7 +12,7 @@ import webdriver from 'next-webdriver'
// test suites // test suites
const context = {} const context: Record<string, any> = {}
describe('getServerSideProps redirects', () => { describe('getServerSideProps redirects', () => {
beforeAll(async () => { beforeAll(async () => {
......
...@@ -18,7 +18,7 @@ const appDir = join(__dirname, '..') ...@@ -18,7 +18,7 @@ const appDir = join(__dirname, '..')
let app let app
let appPort let appPort
const runTests = (isDev) => { const runTests = (isDev: boolean) => {
it('should apply temporary redirect when visited directly for GSSP page', async () => { it('should apply temporary redirect when visited directly for GSSP page', async () => {
const res = await fetchViaHTTP( const res = await fetchViaHTTP(
appPort, appPort,
...@@ -103,7 +103,7 @@ const runTests = (isDev) => { ...@@ -103,7 +103,7 @@ const runTests = (isDev) => {
post: 'first', post: 'first',
}, },
}) })
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
const { pathname } = url.parse(initialHref) const { pathname } = url.parse(initialHref)
expect(pathname).toBe('/gsp-blog/redirect-dest-_gsp-blog_first') expect(pathname).toBe('/gsp-blog/redirect-dest-_gsp-blog_first')
}) })
...@@ -125,7 +125,7 @@ const runTests = (isDev) => { ...@@ -125,7 +125,7 @@ const runTests = (isDev) => {
post: 'first', post: 'first',
}, },
}) })
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
const { pathname } = url.parse(initialHref) const { pathname } = url.parse(initialHref)
expect(pathname).toBe('/gsp-blog/first') expect(pathname).toBe('/gsp-blog/first')
}) })
...@@ -147,7 +147,7 @@ const runTests = (isDev) => { ...@@ -147,7 +147,7 @@ const runTests = (isDev) => {
post: 'first', post: 'first',
}, },
}) })
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
const { pathname } = url.parse(initialHref) const { pathname } = url.parse(initialHref)
expect(pathname).toBe('/gsp-blog/first') expect(pathname).toBe('/gsp-blog/first')
}) })
...@@ -169,7 +169,7 @@ const runTests = (isDev) => { ...@@ -169,7 +169,7 @@ const runTests = (isDev) => {
post: 'first', post: 'first',
}, },
}) })
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
const { pathname } = url.parse(initialHref) const { pathname } = url.parse(initialHref)
expect(pathname).toBe('/gsp-blog/first') expect(pathname).toBe('/gsp-blog/first')
}) })
...@@ -191,7 +191,7 @@ const runTests = (isDev) => { ...@@ -191,7 +191,7 @@ const runTests = (isDev) => {
post: 'first', post: 'first',
}, },
}) })
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
const { pathname } = url.parse(initialHref) const { pathname } = url.parse(initialHref)
expect(pathname).toBe('/gsp-blog/first') expect(pathname).toBe('/gsp-blog/first')
}) })
...@@ -214,7 +214,7 @@ const runTests = (isDev) => { ...@@ -214,7 +214,7 @@ const runTests = (isDev) => {
post: 'first', post: 'first',
}, },
}) })
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
const { pathname } = url.parse(initialHref) const { pathname } = url.parse(initialHref)
// since it was cached the initial value is now the redirect // since it was cached the initial value is now the redirect
// result // result
...@@ -229,7 +229,7 @@ const runTests = (isDev) => { ...@@ -229,7 +229,7 @@ const runTests = (isDev) => {
await browser.waitForElementByCss('#index') await browser.waitForElementByCss('#index')
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
const { pathname } = url.parse(initialHref) const { pathname } = url.parse(initialHref)
expect(pathname).toBe('/gsp-blog/redirect-dest-_') expect(pathname).toBe('/gsp-blog/redirect-dest-_')
}) })
...@@ -242,7 +242,7 @@ const runTests = (isDev) => { ...@@ -242,7 +242,7 @@ const runTests = (isDev) => {
await browser.waitForElementByCss('#index') await browser.waitForElementByCss('#index')
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
const { pathname } = url.parse(initialHref) const { pathname } = url.parse(initialHref)
expect(pathname).toBe('/') expect(pathname).toBe('/')
}) })
...@@ -262,7 +262,7 @@ const runTests = (isDev) => { ...@@ -262,7 +262,7 @@ const runTests = (isDev) => {
/oops not found/ /oops not found/
) )
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
expect(initialHref).toBeFalsy() expect(initialHref).toBeFalsy()
const curUrl = await browser.url() const curUrl = await browser.url()
...@@ -284,7 +284,7 @@ const runTests = (isDev) => { ...@@ -284,7 +284,7 @@ const runTests = (isDev) => {
'example.vercel.sh' 'example.vercel.sh'
) )
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
expect(initialHref).toBeFalsy() expect(initialHref).toBeFalsy()
}) })
...@@ -302,7 +302,7 @@ const runTests = (isDev) => { ...@@ -302,7 +302,7 @@ const runTests = (isDev) => {
'example.vercel.sh' 'example.vercel.sh'
) )
const initialHref = await browser.eval(() => window.initialHref) const initialHref = await browser.eval(() => (window as any).initialHref)
expect(initialHref).toBeFalsy() expect(initialHref).toBeFalsy()
const res = await fetchViaHTTP( const res = await fetchViaHTTP(
...@@ -537,7 +537,7 @@ describe('GS(S)P Redirect Support', () => { ...@@ -537,7 +537,7 @@ describe('GS(S)P Redirect Support', () => {
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests() runTests(false)
it('should not have errors in output', async () => { it('should not have errors in output', async () => {
expect(output).not.toContain('Failed to update prerender files') expect(output).not.toContain('Failed to update prerender files')
......
...@@ -46,7 +46,7 @@ describe('Hashbang', () => { ...@@ -46,7 +46,7 @@ describe('Hashbang', () => {
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests(true) runTests()
} }
) )
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
......
...@@ -15,7 +15,7 @@ import { ...@@ -15,7 +15,7 @@ import {
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
const nextConfig = new File(join(appDir, 'next.config.js')) const nextConfig = new File(join(appDir, 'next.config.js'))
const ctx = { const ctx: Record<string, any> = {
basePath: '/docs', basePath: '/docs',
appDir, appDir,
} }
...@@ -27,14 +27,14 @@ describe('i18n Support basePath', () => { ...@@ -27,14 +27,14 @@ describe('i18n Support basePath', () => {
res.statusCode = 200 res.statusCode = 200
res.end(JSON.stringify({ url: req.url, external: true })) res.end(JSON.stringify({ url: req.url, external: true }))
}) })
await new Promise((resolve, reject) => { await new Promise<void>((resolve, reject) => {
ctx.externalApp.listen(ctx.externalPort, (err) => ctx.externalApp.listen(ctx.externalPort, (err) =>
err ? reject(err) : resolve() err ? reject(err) : resolve()
) )
}) })
}) })
afterAll(async () => { afterAll(async () => {
await new Promise((resolve, reject) => await new Promise<void>((resolve, reject) =>
ctx.externalApp.close((err) => { ctx.externalApp.close((err) => {
err ? reject(err) : resolve() err ? reject(err) : resolve()
}) })
...@@ -43,7 +43,7 @@ describe('i18n Support basePath', () => { ...@@ -43,7 +43,7 @@ describe('i18n Support basePath', () => {
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode', 'development mode',
() => { () => {
const curCtx = { const curCtx: Record<string, any> = {
...ctx, ...ctx,
isDev: true, isDev: true,
} }
......
...@@ -21,17 +21,13 @@ let buildPagesDir ...@@ -21,17 +21,13 @@ let buildPagesDir
const locales = ['en-US', 'nl-NL', 'nl-BE', 'nl', 'fr-BE', 'fr', 'en'] const locales = ['en-US', 'nl-NL', 'nl-BE', 'nl', 'fr-BE', 'fr', 'en']
function runTests(isDev) { function runTests(isDev: boolean) {
if (!isDev) { if (!isDev) {
it('should output prerendered index routes correctly', async () => { it('should output prerendered index routes correctly', async () => {
expect(await fs.exists(join(buildPagesDir, 'pages/en-US.html'))).toBe( expect(fs.existsSync(join(buildPagesDir, 'pages/en-US.html'))).toBe(true)
true expect(fs.existsSync(join(buildPagesDir, 'pages/en-US.json'))).toBe(true)
) expect(fs.existsSync(join(buildPagesDir, 'pages/fr.html'))).toBe(true)
expect(await fs.exists(join(buildPagesDir, 'pages/en-US.json'))).toBe( expect(fs.existsSync(join(buildPagesDir, 'pages/fr.json'))).toBe(true)
true
)
expect(await fs.exists(join(buildPagesDir, 'pages/fr.html'))).toBe(true)
expect(await fs.exists(join(buildPagesDir, 'pages/fr.json'))).toBe(true)
}) })
} }
...@@ -246,7 +242,7 @@ describe('i18n Support Root Catch-all', () => { ...@@ -246,7 +242,7 @@ describe('i18n Support Root Catch-all', () => {
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests() runTests(false)
} }
) )
}) })
...@@ -116,7 +116,7 @@ describe('Custom routes i18n custom error', () => { ...@@ -116,7 +116,7 @@ describe('Custom routes i18n custom error', () => {
app = await launchApp(appDir, appPort) app = await launchApp(appDir, appPort)
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests(true) runTests()
} }
) )
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
......
...@@ -27,7 +27,7 @@ function runTests() { ...@@ -27,7 +27,7 @@ function runTests() {
['/', { hello: 'world' }], ['/', { hello: 'world' }],
['/en', { hello: 'world' }], ['/en', { hello: 'world' }],
['/fr', { hello: 'world' }], ['/fr', { hello: 'world' }],
]) { ] as const) {
const asPath = url.format({ pathname, query }) const asPath = url.format({ pathname, query })
const browser = await webdriver(appPort, asPath) const browser = await webdriver(appPort, asPath)
...@@ -56,7 +56,7 @@ function runTests() { ...@@ -56,7 +56,7 @@ function runTests() {
['/dynamic/first', { hello: 'world' }], ['/dynamic/first', { hello: 'world' }],
['/en/dynamic/first', { hello: 'world' }], ['/en/dynamic/first', { hello: 'world' }],
['/fr/dynamic/first', { hello: 'world' }], ['/fr/dynamic/first', { hello: 'world' }],
]) { ] as const) {
const asPath = url.format({ pathname, query }) const asPath = url.format({ pathname, query })
const browser = await webdriver(appPort, asPath) const browser = await webdriver(appPort, asPath)
......
...@@ -27,7 +27,7 @@ function runTests() { ...@@ -27,7 +27,7 @@ function runTests() {
['/', { hello: 'world' }], ['/', { hello: 'world' }],
['/en', { hello: 'world' }], ['/en', { hello: 'world' }],
['/fr', { hello: 'world' }], ['/fr', { hello: 'world' }],
]) { ] as const) {
const asPath = url.format({ pathname, query }) const asPath = url.format({ pathname, query })
const browser = await webdriver(appPort, asPath) const browser = await webdriver(appPort, asPath)
...@@ -56,7 +56,7 @@ function runTests() { ...@@ -56,7 +56,7 @@ function runTests() {
['/dynamic/first', { hello: 'world' }], ['/dynamic/first', { hello: 'world' }],
['/en/dynamic/first', { hello: 'world' }], ['/en/dynamic/first', { hello: 'world' }],
['/fr/dynamic/first', { hello: 'world' }], ['/fr/dynamic/first', { hello: 'world' }],
]) { ] as const) {
const asPath = url.format({ pathname, query }) const asPath = url.format({ pathname, query })
const browser = await webdriver(appPort, asPath) const browser = await webdriver(appPort, asPath)
......
...@@ -84,7 +84,7 @@ describe('Custom routes i18n support index rewrite', () => { ...@@ -84,7 +84,7 @@ describe('Custom routes i18n support index rewrite', () => {
app = await launchApp(appDir, appPort) app = await launchApp(appDir, appPort)
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests(true) runTests()
} }
) )
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
......
...@@ -79,7 +79,7 @@ describe('Hash changes i18n', () => { ...@@ -79,7 +79,7 @@ describe('Hash changes i18n', () => {
app = await launchApp(appDir, appPort) app = await launchApp(appDir, appPort)
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests(true) runTests()
} }
) )
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
......
...@@ -19,7 +19,7 @@ import assert from 'assert' ...@@ -19,7 +19,7 @@ import assert from 'assert'
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
const nextConfig = new File(join(appDir, 'next.config.js')) const nextConfig = new File(join(appDir, 'next.config.js'))
const ctx = { const ctx: Record<string, any> = {
basePath: '', basePath: '',
appDir, appDir,
} }
...@@ -31,7 +31,7 @@ describe('i18n Support', () => { ...@@ -31,7 +31,7 @@ describe('i18n Support', () => {
res.statusCode = 200 res.statusCode = 200
res.end(JSON.stringify({ url: req.url, external: true })) res.end(JSON.stringify({ url: req.url, external: true }))
}) })
await new Promise((resolve, reject) => { await new Promise<void>((resolve, reject) => {
ctx.externalApp.listen(ctx.externalPort, (err) => ctx.externalApp.listen(ctx.externalPort, (err) =>
err ? reject(err) : resolve() err ? reject(err) : resolve()
) )
...@@ -41,7 +41,7 @@ describe('i18n Support', () => { ...@@ -41,7 +41,7 @@ describe('i18n Support', () => {
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode', 'development mode',
() => { () => {
const curCtx = { const curCtx: Record<string, any> = {
...ctx, ...ctx,
isDev: true, isDev: true,
} }
...@@ -426,7 +426,7 @@ describe('i18n Support', () => { ...@@ -426,7 +426,7 @@ describe('i18n Support', () => {
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode', 'development mode',
() => { () => {
const curCtx = { const curCtx: Record<string, any> = {
...ctx, ...ctx,
isDev: true, isDev: true,
} }
...@@ -496,7 +496,7 @@ describe('i18n Support', () => { ...@@ -496,7 +496,7 @@ describe('i18n Support', () => {
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode', 'development mode',
() => { () => {
const curCtx = { const curCtx: Record<string, any> = {
...ctx, ...ctx,
isDev: true, isDev: true,
} }
......
...@@ -40,7 +40,7 @@ describe('Custom routes invalid multi-match', () => { ...@@ -40,7 +40,7 @@ describe('Custom routes invalid multi-match', () => {
}) })
}) })
afterAll(() => killApp(app)) afterAll(() => killApp(app))
runTests(true) runTests()
} }
) )
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
......
...@@ -6,7 +6,10 @@ const warningMessage = ...@@ -6,7 +6,10 @@ const warningMessage =
describe('Invalid server options', () => { describe('Invalid server options', () => {
test('next() called with no parameters should throw error', () => { test('next() called with no parameters should throw error', () => {
expect(() => next()).toThrow( expect(() =>
// @ts-expect-error
next()
).toThrow(
'The server has not been instantiated properly. https://nextjs.org/docs/messages/invalid-server-options' 'The server has not been instantiated properly. https://nextjs.org/docs/messages/invalid-server-options'
) )
}) })
...@@ -25,7 +28,7 @@ describe('Invalid server options', () => { ...@@ -25,7 +28,7 @@ describe('Invalid server options', () => {
test('next() called with dev as string should send warning', () => { test('next() called with dev as string should send warning', () => {
const consoleSpy = jest.spyOn(console, 'warn') const consoleSpy = jest.spyOn(console, 'warn')
const dev = 'string' const dev: any = 'string'
next({ dev, dir }) next({ dev, dir })
expect(consoleSpy).toHaveBeenCalledWith(warningMessage) expect(consoleSpy).toHaveBeenCalledWith(warningMessage)
...@@ -33,7 +36,7 @@ describe('Invalid server options', () => { ...@@ -33,7 +36,7 @@ describe('Invalid server options', () => {
test('next() called with dev as number should send warning', () => { test('next() called with dev as number should send warning', () => {
const consoleSpy = jest.spyOn(console, 'warn') const consoleSpy = jest.spyOn(console, 'warn')
const dev = 123 const dev: any = 123
next({ dev, dir }) next({ dev, dir })
expect(consoleSpy).toHaveBeenCalledWith(warningMessage) expect(consoleSpy).toHaveBeenCalledWith(warningMessage)
...@@ -41,7 +44,7 @@ describe('Invalid server options', () => { ...@@ -41,7 +44,7 @@ describe('Invalid server options', () => {
test('next() called with dev as array should send warning', () => { test('next() called with dev as array should send warning', () => {
const consoleSpy = jest.spyOn(console, 'warn') const consoleSpy = jest.spyOn(console, 'warn')
const dev = ['array'] const dev: any = ['array']
next({ dev, dir }) next({ dev, dir })
expect(consoleSpy).toHaveBeenCalledWith(warningMessage) expect(consoleSpy).toHaveBeenCalledWith(warningMessage)
...@@ -49,7 +52,7 @@ describe('Invalid server options', () => { ...@@ -49,7 +52,7 @@ describe('Invalid server options', () => {
test('next() called with dev as object should send warning', () => { test('next() called with dev as object should send warning', () => {
const consoleSpy = jest.spyOn(console, 'warn') const consoleSpy = jest.spyOn(console, 'warn')
const dev = { test: 'goes here' } const dev: any = { test: 'goes here' }
next({ dev, dir }) next({ dev, dir })
expect(consoleSpy).toHaveBeenCalledWith(warningMessage) expect(consoleSpy).toHaveBeenCalledWith(warningMessage)
...@@ -57,7 +60,7 @@ describe('Invalid server options', () => { ...@@ -57,7 +60,7 @@ describe('Invalid server options', () => {
test('next() called with dev as function should send warning', () => { test('next() called with dev as function should send warning', () => {
const consoleSpy = jest.spyOn(console, 'warn') const consoleSpy = jest.spyOn(console, 'warn')
const dev = () => console.log('test') const dev: any = () => console.log('test')
next({ dev, dir }) next({ dev, dir })
expect(consoleSpy).toHaveBeenCalledWith(warningMessage) expect(consoleSpy).toHaveBeenCalledWith(warningMessage)
......
{ {
"compilerOptions": { "compilerOptions": {
"baseUrl": "." "baseUrl": "."
} },
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
} }
...@@ -17,7 +17,7 @@ const appDir = join(__dirname, '..') ...@@ -17,7 +17,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)
} }
......
...@@ -4,5 +4,6 @@ ...@@ -4,5 +4,6 @@
"paths": { "paths": {
"*": ["node_modules/*"] "*": ["node_modules/*"]
} }
} },
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
} }
...@@ -16,7 +16,7 @@ const appDir = join(__dirname, '..') ...@@ -16,7 +16,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)
} }
......
...@@ -6,5 +6,6 @@ ...@@ -6,5 +6,6 @@
"@lib/*": ["lib/a/*", "lib/b/*"], "@lib/*": ["lib/a/*", "lib/b/*"],
"@mycomponent": ["components/hello.js"] "@mycomponent": ["components/hello.js"]
} }
} },
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
} }
...@@ -20,7 +20,7 @@ const appDir = join(__dirname, '..') ...@@ -20,7 +20,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)
} }
......
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