From 994d8ee2c3d7cff8b9accd89ecc94a866d0bd907 Mon Sep 17 00:00:00 2001 From: Hendrik Liebau Date: Mon, 3 Jun 2024 14:56:49 +0200 Subject: [PATCH] Fix broken `BrowserInterface` type (#66461) --- .../strict-mode-enabled-by-default.test.ts | 3 +- .../define-class-fields.test.ts | 2 +- test/development/basic/misc.test.ts | 2 +- .../basic/next-dynamic/next-dynamic.test.ts | 2 +- .../styled-components.test.ts | 2 +- .../pages-dir/client-navigation/index.test.ts | 8 +- .../autoscroll-with-css-modules/index.test.ts | 4 +- test/e2e/app-dir/next-after-app/index.test.ts | 3 +- .../root-layout-redirect.test.ts | 2 +- .../layout-params.test.ts | 5 +- test/e2e/new-link-behavior/index.test.ts | 2 +- test/integration/app-document/test/csp.js | 4 +- .../next-image-new/app-dir/test/index.test.ts | 14 ++-- .../base-path/test/index.test.js | 4 +- .../next-image-new/default/test/index.test.ts | 12 +-- .../script-loader/test/index.test.js | 2 +- test/lib/browsers/base.ts | 82 +++++++++---------- test/lib/browsers/playwright.ts | 38 ++++----- .../pages-dir/production/test/index.test.ts | 6 +- tsconfig.base.json | 23 ------ tsconfig.json | 25 +++++- 21 files changed, 112 insertions(+), 133 deletions(-) delete mode 100644 tsconfig.base.json diff --git a/test/development/app-dir/strict-mode-enabled-by-default/strict-mode-enabled-by-default.test.ts b/test/development/app-dir/strict-mode-enabled-by-default/strict-mode-enabled-by-default.test.ts index ea9443d57d..11a52c017e 100644 --- a/test/development/app-dir/strict-mode-enabled-by-default/strict-mode-enabled-by-default.test.ts +++ b/test/development/app-dir/strict-mode-enabled-by-default/strict-mode-enabled-by-default.test.ts @@ -1,4 +1,3 @@ -import { type BrowserInterface } from 'next-webdriver' import { nextTestSetup } from 'e2e-utils' import { check } from 'next-test-utils' @@ -8,7 +7,7 @@ describe('Strict Mode enabled by default', () => { }) // TODO: modern StrictMode does not double invoke effects during hydration: https://github.com/facebook/react/pull/28951 it.skip('should work using browser', async () => { - const browser: BrowserInterface = await next.browser('/') + const browser = await next.browser('/') await check(async () => { const text = await browser.elementByCss('p').text() // FIXME: Bug in React. Strict Effects no longer work in current beta. diff --git a/test/development/basic/define-class-fields/define-class-fields.test.ts b/test/development/basic/define-class-fields/define-class-fields.test.ts index 837a9cf3e2..094838705b 100644 --- a/test/development/basic/define-class-fields/define-class-fields.test.ts +++ b/test/development/basic/define-class-fields/define-class-fields.test.ts @@ -48,7 +48,7 @@ describe('useDefineForClassFields SWC option', () => { let data_foundLog = false let name_foundLog = false - const browserLogs = await browser.log('browser') + const browserLogs = await browser.log() browserLogs.forEach((log) => { if (log.message.includes('data changed')) { diff --git a/test/development/basic/misc.test.ts b/test/development/basic/misc.test.ts index af13254568..9251e62f69 100644 --- a/test/development/basic/misc.test.ts +++ b/test/development/basic/misc.test.ts @@ -85,7 +85,7 @@ describe.each([[''], ['/docs']])( let browser try { browser = await webdriver(next.url, path) - const browserLogs = await browser.log('browser') + const browserLogs = await browser.log() browserLogs.forEach((log) => { if (log.message.includes('Next.js auto-prefetches automatically')) { diff --git a/test/development/basic/next-dynamic/next-dynamic.test.ts b/test/development/basic/next-dynamic/next-dynamic.test.ts index 95a9c7b5fd..5e10a9a7a4 100644 --- a/test/development/basic/next-dynamic/next-dynamic.test.ts +++ b/test/development/basic/next-dynamic/next-dynamic.test.ts @@ -119,7 +119,7 @@ describe('next/dynamic', () => { ) if ((global as any).browserName === 'chrome') { - const logs = await browser.log('browser') + const logs = await browser.log() logs.forEach((logItem) => { expect(logItem.message).not.toMatch( diff --git a/test/development/basic/styled-components/styled-components.test.ts b/test/development/basic/styled-components/styled-components.test.ts index a74aba499a..4a76c4d7e9 100644 --- a/test/development/basic/styled-components/styled-components.test.ts +++ b/test/development/basic/styled-components/styled-components.test.ts @@ -12,7 +12,7 @@ describe('styled-components SWC transform', () => { async function matchLogs$(browser) { let foundLog = false - const browserLogs = await browser.log('browser') + const browserLogs = await browser.log() browserLogs.forEach((log) => { if (log.message.includes('Warning: Prop `%s` did not match.')) { diff --git a/test/development/pages-dir/client-navigation/index.test.ts b/test/development/pages-dir/client-navigation/index.test.ts index f66d8f23d0..52736fe4da 100644 --- a/test/development/pages-dir/client-navigation/index.test.ts +++ b/test/development/pages-dir/client-navigation/index.test.ts @@ -565,7 +565,7 @@ describe('Client Navigation', () => { describe('check hydration mis-match', () => { it('should not have hydration mis-match for hash link', async () => { const browser = await webdriver(next.appPort, '/nav/hash-changes') - const browserLogs = await browser.log('browser') + const browserLogs = await browser.log() let found = false browserLogs.forEach((log) => { console.log('log.message', log.message) @@ -1717,7 +1717,7 @@ describe.each([[false], [true]])( await browser.waitForElementByCss('h1') await waitFor(1000) - const browserLogs = await browser.log('browser') + const browserLogs = await browser.log() let foundStyles = false let foundScripts = false const logs = [] @@ -1750,7 +1750,7 @@ describe.each([[false], [true]])( browser = await webdriver(next.appPort, '/head') await browser.waitForElementByCss('h1') await waitFor(1000) - const browserLogs = await browser.log('browser') + const browserLogs = await browser.log() let found = false browserLogs.forEach((log) => { if (log.message.includes('Use next/script instead')) { @@ -1771,7 +1771,7 @@ describe.each([[false], [true]])( browser = await webdriver(next.appPort, '/head-with-json-ld-snippet') await browser.waitForElementByCss('h1') await waitFor(1000) - const browserLogs = await browser.log('browser') + const browserLogs = await browser.log() let found = false browserLogs.forEach((log) => { if (log.message.includes('Use next/script instead')) { diff --git a/test/e2e/app-dir/autoscroll-with-css-modules/index.test.ts b/test/e2e/app-dir/autoscroll-with-css-modules/index.test.ts index bff16ba68f..a31d0da5cf 100644 --- a/test/e2e/app-dir/autoscroll-with-css-modules/index.test.ts +++ b/test/e2e/app-dir/autoscroll-with-css-modules/index.test.ts @@ -36,7 +36,7 @@ describe('router autoscrolling on navigation with css modules', () => { describe('vertical scroll when page imports css modules', () => { it('should scroll to top of document when navigating between to pages without layout when', async () => { - const browser: BrowserInterface = await next.browser('/1') + const browser = await next.browser('/1') await scrollTo(browser, { x: 0, y: 1000 }) expect(await getTopScroll(browser)).toBe(1000) @@ -46,7 +46,7 @@ describe('router autoscrolling on navigation with css modules', () => { }) it('should scroll when clicking in JS', async () => { - const browser: BrowserInterface = await next.browser('/1') + const browser = await next.browser('/1') await scrollTo(browser, { x: 0, y: 1000 }) expect(await getTopScroll(browser)).toBe(1000) diff --git a/test/e2e/app-dir/next-after-app/index.test.ts b/test/e2e/app-dir/next-after-app/index.test.ts index 18ba40e0ba..9ae34b30b5 100644 --- a/test/e2e/app-dir/next-after-app/index.test.ts +++ b/test/e2e/app-dir/next-after-app/index.test.ts @@ -8,7 +8,6 @@ import * as fs from 'fs' import * as path from 'path' import * as os from 'os' import * as Log from './utils/log' -import { BrowserInterface } from '../../../lib/next-webdriver' const runtimes = ['nodejs', 'edge'] @@ -257,7 +256,7 @@ describe.each(runtimes)('unstable_after() in %s runtime', (runtimeValue) => { const EXPECTED_ERROR = /An error occurred in a function passed to `unstable_after\(\)`: .+?: Cookies can only be modified in a Server Action or Route Handler\./ - const browser: BrowserInterface = await next.browser('/123/setting-cookies') + const browser = await next.browser('/123/setting-cookies') // after() from render expect(next.cliOutput).toMatch(EXPECTED_ERROR) diff --git a/test/e2e/app-dir/root-layout-redirect/root-layout-redirect.test.ts b/test/e2e/app-dir/root-layout-redirect/root-layout-redirect.test.ts index d2c0801ff9..646fa8f0be 100644 --- a/test/e2e/app-dir/root-layout-redirect/root-layout-redirect.test.ts +++ b/test/e2e/app-dir/root-layout-redirect/root-layout-redirect.test.ts @@ -16,7 +16,7 @@ describe('root-layout-redirect', () => { .text() ).toBe('Result Page') - const browserLogs = await browser.log('browser') + const browserLogs = await browser.log() let foundErrors = false diff --git a/test/e2e/app-dir/search-params-react-key/layout-params.test.ts b/test/e2e/app-dir/search-params-react-key/layout-params.test.ts index 89f8d0f8ed..07b5a77336 100644 --- a/test/e2e/app-dir/search-params-react-key/layout-params.test.ts +++ b/test/e2e/app-dir/search-params-react-key/layout-params.test.ts @@ -9,7 +9,10 @@ describe('app dir - search params keys', () => { it('should keep the React router instance the same when changing the search params', async () => { const browser = await next.browser('/') - const searchParams = browser.waitForElementByCss('#search-params').text() + const searchParams = await browser + .waitForElementByCss('#search-params') + .text() + await browser.elementByCss('#increment').click() await browser.elementByCss('#increment').click() diff --git a/test/e2e/new-link-behavior/index.test.ts b/test/e2e/new-link-behavior/index.test.ts index 68280d073c..aecc0dcc82 100644 --- a/test/e2e/new-link-behavior/index.test.ts +++ b/test/e2e/new-link-behavior/index.test.ts @@ -8,7 +8,7 @@ import path from 'path' async function matchLogs(browser, includes: string) { let found = false - const browserLogs = await browser.log('browser') + const browserLogs = await browser.log() browserLogs.forEach((log) => { if (log.message.includes(includes)) { diff --git a/test/integration/app-document/test/csp.js b/test/integration/app-document/test/csp.js index 268b48acaa..2b8c34ad58 100644 --- a/test/integration/app-document/test/csp.js +++ b/test/integration/app-document/test/csp.js @@ -6,7 +6,7 @@ export default (context, render) => { it('should load inline script by hash', async () => { const browser = await webdriver(context.appPort, '/?withCSP=hash') if (global.browserName === 'chrome') { - const errLog = await browser.log('browser') + const errLog = await browser.log() expect(errLog.filter((e) => e.source === 'security')).toEqual([]) } await browser.close() @@ -15,7 +15,7 @@ export default (context, render) => { it('should load inline script by nonce', async () => { const browser = await webdriver(context.appPort, '/?withCSP=nonce') if (global.browserName === 'chrome') { - const errLog = await browser.log('browser') + const errLog = await browser.log() expect(errLog.filter((e) => e.source === 'security')).toEqual([]) } await browser.close() diff --git a/test/integration/next-image-new/app-dir/test/index.test.ts b/test/integration/next-image-new/app-dir/test/index.test.ts index 25a8250144..ef458860a5 100644 --- a/test/integration/next-image-new/app-dir/test/index.test.ts +++ b/test/integration/next-image-new/app-dir/test/index.test.ts @@ -238,7 +238,7 @@ function runTests(mode) { await browser.elementById('belowthefold').getAttribute('loading') ).toBe(null) - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(warnings).not.toMatch( @@ -381,7 +381,7 @@ function runTests(mode) { ) if (mode === 'dev') { - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(warnings).toMatch( @@ -657,7 +657,7 @@ function runTests(mode) { ) if (mode === 'dev') { await waitFor(1000) - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(warnings).toMatch( @@ -1064,7 +1064,7 @@ function runTests(mode) { return 'done' }, 'done') await waitFor(1000) - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(await hasRedbox(browser)).toBe(false) @@ -1353,7 +1353,7 @@ function runTests(mode) { if (mode === 'dev') { it('should not log incorrect warnings', async () => { await waitFor(1000) - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(warnings).not.toMatch(/Image with src (.*) has "fill"/gm) @@ -1364,7 +1364,7 @@ function runTests(mode) { it('should log warnings when using fill mode incorrectly', async () => { browser = await webdriver(appPort, '/fill-warnings') await waitFor(1000) - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(warnings).toContain( @@ -1383,7 +1383,7 @@ function runTests(mode) { it('should not log warnings when image unmounts', async () => { browser = await webdriver(appPort, '/should-not-warn-unmount') await waitFor(1000) - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(warnings).not.toContain( diff --git a/test/integration/next-image-new/base-path/test/index.test.js b/test/integration/next-image-new/base-path/test/index.test.js index dc9bdb4b77..ecfb04eb39 100644 --- a/test/integration/next-image-new/base-path/test/index.test.js +++ b/test/integration/next-image-new/base-path/test/index.test.js @@ -133,9 +133,7 @@ function runTests(mode) { expect(await hasRedbox(browser)).toBe(false) await check(async () => { - return (await browser.log('browser')) - .map((log) => log.message) - .join('\n') + return (await browser.log()).map((log) => log.message).join('\n') }, /Image is missing required "src" property/gm) }) diff --git a/test/integration/next-image-new/default/test/index.test.ts b/test/integration/next-image-new/default/test/index.test.ts index 7796fc98a0..044598f895 100644 --- a/test/integration/next-image-new/default/test/index.test.ts +++ b/test/integration/next-image-new/default/test/index.test.ts @@ -239,7 +239,7 @@ function runTests(mode) { await browser.elementById('belowthefold').getAttribute('loading') ).toBe(null) - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(warnings).not.toMatch( @@ -382,7 +382,7 @@ function runTests(mode) { ) if (mode === 'dev') { - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(warnings).toMatch( @@ -658,7 +658,7 @@ function runTests(mode) { ) if (mode === 'dev') { await waitFor(1000) - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(warnings).toMatch( @@ -1355,7 +1355,7 @@ function runTests(mode) { if (mode === 'dev') { it('should not log incorrect warnings', async () => { await waitFor(1000) - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(warnings).not.toMatch(/Image with src (.*) has "fill"/gm) @@ -1366,7 +1366,7 @@ function runTests(mode) { it('should log warnings when using fill mode incorrectly', async () => { browser = await webdriver(appPort, '/fill-warnings') await waitFor(1000) - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(warnings).toContain( @@ -1385,7 +1385,7 @@ function runTests(mode) { it('should not log warnings when image unmounts', async () => { browser = await webdriver(appPort, '/should-not-warn-unmount') await waitFor(1000) - const warnings = (await browser.log('browser')) + const warnings = (await browser.log()) .map((log) => log.message) .join('\n') expect(warnings).not.toContain( diff --git a/test/integration/script-loader/test/index.test.js b/test/integration/script-loader/test/index.test.js index 86dcd86b8b..3edb8efabb 100644 --- a/test/integration/script-loader/test/index.test.js +++ b/test/integration/script-loader/test/index.test.js @@ -61,7 +61,7 @@ const runTests = (isDev) => { await browser.waitForElementByCss('#onload-div') await waitFor(1000) - const logs = await browser.log('browser') + const logs = await browser.log() const filteredLogs = logs.filter( (log) => !log.message.includes('Failed to load resource') && diff --git a/test/lib/browsers/base.ts b/test/lib/browsers/base.ts index 1475b7eed5..e3393c3a79 100644 --- a/test/lib/browsers/base.ts +++ b/test/lib/browsers/base.ts @@ -5,21 +5,18 @@ export type Event = 'request' * classes should build on, it is the bare * methods we aim to support across tests */ -export abstract class BrowserInterface implements PromiseLike { - private promise?: Promise - then: Promise['then'] - catch: Promise['catch'] - finally: Promise['finally']; +export abstract class BrowserInterface { + private promise?: Promise; // necessary for the type of the function below readonly [Symbol.toStringTag]: string = 'BrowserInterface' - protected chain( - nextCall: (current: any) => T | PromiseLike - ): BrowserInterface & Promise { + protected chain( + nextCall: (current: TCurrent) => TNext | Promise + ): BrowserInterface & Promise { const promise = Promise.resolve(this.promise).then(nextCall) - function get(target: BrowserInterface, p: string | symbol): any { + function get(target: BrowserInterface, p: string | symbol): any { switch (p) { case 'promise': return promise @@ -39,12 +36,6 @@ export abstract class BrowserInterface implements PromiseLike { }) } - protected chainWithReturnValue( - callback: (value: any) => T | PromiseLike - ): Promise { - return Promise.resolve(this.promise).then(callback) - } - abstract setup( browserName: string, locale: string, @@ -54,36 +45,43 @@ export abstract class BrowserInterface implements PromiseLike { ): Promise abstract close(): Promise - abstract elementsByCss(selector: string): BrowserInterface[] - abstract elementByCss(selector: string): BrowserInterface - abstract elementById(selector: string): BrowserInterface - abstract touchStart(): BrowserInterface - abstract click(opts?: { modifierKey?: boolean }): BrowserInterface - abstract keydown(key: string): BrowserInterface - abstract keyup(key: string): BrowserInterface - abstract type(text: string): BrowserInterface - abstract moveTo(): BrowserInterface - // TODO(NEXT-290): type this correctly as awaitable + abstract elementsByCss( + selector: string + ): BrowserInterface & Promise + abstract elementByCss(selector: string): BrowserInterface & Promise + abstract elementById(selector: string): BrowserInterface & Promise + abstract touchStart(): BrowserInterface & Promise + abstract click(): BrowserInterface & Promise + abstract keydown(key: string): BrowserInterface & Promise + abstract keyup(key: string): BrowserInterface & Promise + abstract type(text: string): BrowserInterface & Promise + abstract moveTo(): BrowserInterface & Promise abstract waitForElementByCss( selector: string, timeout?: number - ): BrowserInterface - abstract waitForCondition(snippet: string, timeout?: number): BrowserInterface + ): BrowserInterface & Promise + abstract waitForCondition( + snippet: string, + timeout?: number + ): BrowserInterface & Promise /** * Use browsers `go back` functionality. */ - abstract back(options?: any): BrowserInterface + abstract back(options?: any): BrowserInterface & Promise /** * Use browsers `go forward` functionality. Inverse of back. */ - abstract forward(options?: any): BrowserInterface - abstract refresh(): BrowserInterface + abstract forward(options?: any): BrowserInterface & Promise + abstract refresh(): BrowserInterface & Promise abstract setDimensions(opts: { height: number width: number - }): BrowserInterface - abstract addCookie(opts: { name: string; value: string }): BrowserInterface - abstract deleteCookies(): BrowserInterface + }): BrowserInterface & Promise + abstract addCookie(opts: { + name: string + value: string + }): BrowserInterface & Promise + abstract deleteCookies(): BrowserInterface & Promise abstract on(event: Event, cb: (...args: any[]) => void): void abstract off(event: Event, cb: (...args: any[]) => void): void abstract loadPage( @@ -93,7 +91,7 @@ export abstract class BrowserInterface implements PromiseLike { cpuThrottleRate, beforePageLoad, pushErrorAsConsoleLog, - }: { + }?: { disableCache?: boolean cpuThrottleRate?: number beforePageLoad?: Function @@ -101,20 +99,14 @@ export abstract class BrowserInterface implements PromiseLike { } ): Promise abstract get(url: string): Promise - - abstract getValue(): Promise - abstract getAttribute(name: string): Promise - abstract eval(snippet: string | Function, ...args: any[]): Promise - abstract evalAsync( - snippet: string | Function, - ...args: any[] - ): Promise + abstract getValue(): Promise + abstract getAttribute(name: string): Promise + abstract eval(snippet: string | Function, ...args: any[]): Promise + abstract evalAsync(snippet: string | Function, ...args: any[]): Promise abstract text(): Promise abstract getComputedCss(prop: string): Promise abstract hasElementByCssSelector(selector: string): Promise - abstract log(): Promise< - { source: 'error' | 'info' | 'log'; message: string }[] - > + abstract log(): Promise<{ source: string; message: string }[]> abstract websocketFrames(): Promise abstract url(): Promise abstract waitForIdleNetwork(): Promise diff --git a/test/lib/browsers/playwright.ts b/test/lib/browsers/playwright.ts index 8cfef94344..93563ed765 100644 --- a/test/lib/browsers/playwright.ts +++ b/test/lib/browsers/playwright.ts @@ -280,31 +280,25 @@ export class Playwright extends BrowserInterface { await page.goto(url, { waitUntil: 'load' }) } - back(options): BrowserInterface { + back(options) { return this.chain(async () => { await page.goBack(options) }) } - forward(options): BrowserInterface { + forward(options) { return this.chain(async () => { await page.goForward(options) }) } - refresh(): BrowserInterface { + refresh() { return this.chain(async () => { await page.reload() }) } - setDimensions({ - width, - height, - }: { - height: number - width: number - }): BrowserInterface { + setDimensions({ width, height }: { height: number; width: number }) { return this.chain(() => page.setViewportSize({ width, height })) } - addCookie(opts: { name: string; value: string }): BrowserInterface { + addCookie(opts: { name: string; value: string }) { return this.chain(async () => context.addCookies([ { @@ -315,7 +309,7 @@ export class Playwright extends BrowserInterface { ]) ) } - deleteCookies(): BrowserInterface { + deleteCookies() { return this.chain(async () => context.clearCookies()) } @@ -373,21 +367,21 @@ export class Playwright extends BrowserInterface { }) as any } - async getAttribute(attr) { - return this.chain((el: ElementHandleExt) => el.getAttribute(attr)) as T + async getAttribute(attr) { + return this.chain((el: ElementHandleExt) => el.getAttribute(attr)) } hasElementByCssSelector(selector: string) { return this.eval(`!!document.querySelector('${selector}')`) } - keydown(key: string): BrowserInterface { + keydown(key: string) { return this.chain((el: ElementHandleExt) => { return page.keyboard.down(key).then(() => el) }) } - keyup(key: string): BrowserInterface { + keyup(key: string) { return this.chain((el: ElementHandleExt) => { return page.keyboard.up(key).then(() => el) }) @@ -418,7 +412,7 @@ export class Playwright extends BrowserInterface { return el }) }) - ) as any as BrowserInterface[] + ) } waitForElementByCss(selector, timeout?: number) { @@ -441,7 +435,7 @@ export class Playwright extends BrowserInterface { } eval(fn: any, ...args: any[]): Promise { - return this.chainWithReturnValue(() => + return this.chain(() => page .evaluate(fn, ...args) .catch((err) => { @@ -455,7 +449,7 @@ export class Playwright extends BrowserInterface { ) } - async evalAsync(fn: any, ...args: any[]) { + async evalAsync(fn: any) { if (typeof fn === 'function') { fn = fn.toString() } @@ -477,15 +471,15 @@ export class Playwright extends BrowserInterface { } async log() { - return this.chain(() => pageLogs) as any + return this.chain(() => pageLogs) } async websocketFrames() { - return this.chain(() => websocketFrames) as any + return this.chain(() => websocketFrames) } async url() { - return this.chain(() => page.evaluate('window.location.href')) as any + return this.chain(() => page.url()) } async waitForIdleNetwork(): Promise { diff --git a/test/production/pages-dir/production/test/index.test.ts b/test/production/pages-dir/production/test/index.test.ts index 5304fa9ef0..388efbd749 100644 --- a/test/production/pages-dir/production/test/index.test.ts +++ b/test/production/pages-dir/production/test/index.test.ts @@ -706,9 +706,7 @@ describe('Production Usage', () => { // @ts-expect-error Exists on window window.__DATA_BE_GONE = 'true' }) - await browser - .waitForElementByCss('#to-nonexistent-page') - .click('#to-nonexistent-page') + await browser.waitForElementByCss('#to-nonexistent-page').click() await browser.waitForElementByCss('.about-page') const oldData = await browser.eval(`window.__DATA_BE_GONE`) @@ -1082,7 +1080,7 @@ describe('Production Usage', () => { let browser try { browser = await webdriver(next.appPort, '/development-logs') - const browserLogs = await browser.log('browser') + const browserLogs = await browser.log() let found = false browserLogs.forEach((log) => { if (log.message.includes('Next.js auto-prefetches automatically')) { diff --git a/tsconfig.base.json b/tsconfig.base.json deleted file mode 100644 index ba074f2bae..0000000000 --- a/tsconfig.base.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "strict": false, - "noEmit": true, - "allowJs": true, - "resolveJsonModule": true, - "jsx": "react-jsx", - "module": "esnext", - "target": "ESNext", - "esModuleInterop": true, - "moduleResolution": "node", - "types": ["react", "jest", "node", "trusted-types", "jest-extended"], - "paths": { - "development-sandbox": ["./test/lib/development-sandbox"], - "next-test-utils": ["./test/lib/next-test-utils"], - "amp-test-utils": ["./test/lib/amp-test-utils"], - "next-webdriver": ["./test/lib/next-webdriver"], - "e2e-utils": ["./test/lib/e2e-utils"], - "test-data-service/*": ["./test/lib/test-data-service/*"], - "test-log": ["./test/lib/test-log"] - } - } -} diff --git a/tsconfig.json b/tsconfig.json index f35f67680c..faab59228f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,24 @@ { - "extends": "./tsconfig.base.json", - "include": ["test/**/*.test.ts", "test/**/*.test.tsx"], - "exclude": ["node_modules"] + "compilerOptions": { + "strict": false, + "noEmit": true, + "allowJs": true, + "resolveJsonModule": true, + "jsx": "react-jsx", + "module": "esnext", + "target": "ESNext", + "esModuleInterop": true, + "moduleResolution": "node", + "types": ["react", "jest", "node", "trusted-types", "jest-extended"], + "paths": { + "development-sandbox": ["./test/lib/development-sandbox"], + "next-test-utils": ["./test/lib/next-test-utils"], + "amp-test-utils": ["./test/lib/amp-test-utils"], + "next-webdriver": ["./test/lib/next-webdriver"], + "e2e-utils": ["./test/lib/e2e-utils"], + "test-data-service/*": ["./test/lib/test-data-service/*"], + "test-log": ["./test/lib/test-log"] + } + }, + "include": ["test/**/*.test.ts", "test/**/*.test.tsx", "test/lib/**/*.ts"] }