diff --git a/.eslintrc.js b/.eslintrc.js index 16f41fd3f5b..a1de9853eef 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,141 +1,183 @@ module.exports = { - "root": true, - "env": { - "node": true, - "es6": true - }, + root: true, + env: { + node: true, + es6: true, + }, - "parser": "@typescript-eslint/parser", + parser: '@typescript-eslint/parser', - "plugins": [ - "mocha", - "@typescript-eslint", - "unicorn", - "import" + plugins: ['mocha', '@typescript-eslint', 'unicorn', 'import'], + + extends: ['plugin:prettier/recommended'], + + rules: { + // Error if files are not formatted with Prettier correctly. + 'prettier/prettier': 2, + // syntax preferences + quotes: [ + 2, + 'single', + { + avoidEscape: true, + allowTemplateLiterals: true, + }, ], - - "extends": [ - "plugin:prettier/recommended" + 'spaced-comment': [ + 2, + 'always', + { + markers: ['*'], + }, ], + eqeqeq: [2], + 'accessor-pairs': [ + 2, + { + getWithoutSet: false, + setWithoutGet: false, + }, + ], + 'new-parens': 2, + 'func-call-spacing': 2, + 'prefer-const': 2, - "rules": { - // Error if files are not formatted with Prettier correctly. - "prettier/prettier": 2, - // syntax preferences - "quotes": [2, "single", { - "avoidEscape": true, - "allowTemplateLiterals": true - }], - "spaced-comment": [2, "always", { - "markers": ["*"] - }], - "eqeqeq": [2], - "accessor-pairs": [2, { - "getWithoutSet": false, - "setWithoutGet": false - }], - "new-parens": 2, - "func-call-spacing": 2, - "prefer-const": 2, + 'max-len': [ + 2, + { + /* this setting doesn't impact things as we use Prettier to format + * our code and hence dictate the line length. + * Prettier aims for 80 but sometimes makes the decision to go just + * over 80 chars as it decides that's better than wrapping. ESLint's + * rule defaults to 80 but therefore conflicts with Prettier. So we + * set it to something far higher than Prettier would allow to avoid + * it causing issues and conflicting with Prettier. + */ + code: 200, + comments: 90, + ignoreTemplateLiterals: true, + ignoreUrls: true, + ignoreStrings: true, + ignoreRegExpLiterals: true, + }, + ], + // anti-patterns + 'no-var': 2, + 'no-with': 2, + 'no-multi-str': 2, + 'no-caller': 2, + 'no-implied-eval': 2, + 'no-labels': 2, + 'no-new-object': 2, + 'no-octal-escape': 2, + 'no-self-compare': 2, + 'no-shadow-restricted-names': 2, + 'no-cond-assign': 2, + 'no-debugger': 2, + 'no-dupe-keys': 2, + 'no-duplicate-case': 2, + 'no-empty-character-class': 2, + 'no-unreachable': 2, + 'no-unsafe-negation': 2, + radix: 2, + 'valid-typeof': 2, + 'no-unused-vars': [ + 2, + { + args: 'none', + vars: 'local', + varsIgnorePattern: + '([fx]?describe|[fx]?it|beforeAll|beforeEach|afterAll|afterEach)', + }, + ], + 'no-implicit-globals': [2], - "max-len": [2, { - /* this setting doesn't impact things as we use Prettier to format - * our code and hence dictate the line length. - * Prettier aims for 80 but sometimes makes the decision to go just - * over 80 chars as it decides that's better than wrapping. ESLint's - * rule defaults to 80 but therefore conflicts with Prettier. So we - * set it to something far higher than Prettier would allow to avoid - * it causing issues and conflicting with Prettier. - */ - "code": 200, - "comments": 90, - "ignoreTemplateLiterals": true, - "ignoreUrls": true, - "ignoreStrings": true, - "ignoreRegExpLiterals": true - }], - // anti-patterns - "no-var": 2, - "no-with": 2, - "no-multi-str": 2, - "no-caller": 2, - "no-implied-eval": 2, - "no-labels": 2, - "no-new-object": 2, - "no-octal-escape": 2, - "no-self-compare": 2, - "no-shadow-restricted-names": 2, - "no-cond-assign": 2, - "no-debugger": 2, - "no-dupe-keys": 2, - "no-duplicate-case": 2, - "no-empty-character-class": 2, - "no-unreachable": 2, - "no-unsafe-negation": 2, - "radix": 2, - "valid-typeof": 2, - "no-unused-vars": [2, { "args": "none", "vars": "local", "varsIgnorePattern": "([fx]?describe|[fx]?it|beforeAll|beforeEach|afterAll|afterEach)" }], - "no-implicit-globals": [2], + // es2015 features + 'require-yield': 2, + 'template-curly-spacing': [2, 'never'], - // es2015 features - "require-yield": 2, - "template-curly-spacing": [2, "never"], + // ensure we don't have any it.only or describe.only in prod + 'mocha/no-exclusive-tests': 'error', - // ensure we don't have any it.only or describe.only in prod - "mocha/no-exclusive-tests": "error", + // enforce the variable in a catch block is named error + 'unicorn/catch-error-name': 'error', - // enforce the variable in a catch block is named error - "unicorn/catch-error-name": "error", - - - "no-restricted-imports": ["error", { - patterns: ["*Events"], - paths: [{ - name: "mitt", - message: - "Import Mitt from the vendored location: vendor/mitt/src/index.js", - }], - }], - "import/extensions": ["error", "ignorePackages"] - }, - "overrides": [ - { - "files": ["*.ts"], - "extends": [ - 'plugin:@typescript-eslint/eslint-recommended', - 'plugin:@typescript-eslint/recommended', - ], - "rules": { - "no-unused-vars": 0, - "@typescript-eslint/no-unused-vars": 2, - "func-call-spacing": 0, - "@typescript-eslint/func-call-spacing": 2, - "semi": 0, - "@typescript-eslint/semi": 2, - "@typescript-eslint/no-empty-function": 0, - "@typescript-eslint/no-use-before-define": 0, - // We have to use any on some types so the warning isn't valuable. - "@typescript-eslint/no-explicit-any": 0, - // We don't require explicit return types on basic functions or - // dummy functions in tests, for example - "@typescript-eslint/explicit-function-return-type": 0, - // We know it's bad and use it very sparingly but it's needed :( - "@typescript-eslint/ban-ts-ignore": 0, - "@typescript-eslint/array-type": [2, { - "default": "array-simple" - }] - } - }, - { - "files": ["test-browser/**/*.js"], - "parserOptions": { - "sourceType": "module" + 'no-restricted-imports': [ + 'error', + { + patterns: ['*Events'], + paths: [ + { + name: 'mitt', + message: + 'Import Mitt from the vendored location: vendor/mitt/src/index.js', + }, + ], + }, + ], + 'import/extensions': ['error', 'ignorePackages'], + }, + overrides: [ + { + files: ['*.ts'], + extends: [ + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + ], + rules: { + 'no-unused-vars': 0, + '@typescript-eslint/no-unused-vars': 2, + 'func-call-spacing': 0, + '@typescript-eslint/func-call-spacing': 2, + semi: 0, + '@typescript-eslint/semi': 2, + '@typescript-eslint/no-empty-function': 0, + '@typescript-eslint/no-use-before-define': 0, + // We have to use any on some types so the warning isn't valuable. + '@typescript-eslint/no-explicit-any': 0, + // We don't require explicit return types on basic functions or + // dummy functions in tests, for example + '@typescript-eslint/explicit-function-return-type': 0, + // We know it's bad and use it very sparingly but it's needed :( + '@typescript-eslint/ban-ts-ignore': 0, + /** + * This is the default options (as per + * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md), + * + * Unfortunately there's no way to + */ + '@typescript-eslint/ban-types': [ + 'error', + { + extendDefaults: true, + types: { + /* + * Puppeteer's API accepts generic functions in many places so it's + * not a useful linting rule to ban the `Function` type. This turns off + * the banning of the `Function` type which is a default rule. + */ + Function: false, }, - "env": { - "es6": true, - "browser": true, - "es2020": true - }, - } - ] + }, + ], + '@typescript-eslint/array-type': [ + 2, + { + default: 'array-simple', + }, + ], + }, + }, + { + files: ['test-browser/**/*.js'], + parserOptions: { + sourceType: 'module', + }, + env: { + es6: true, + browser: true, + es2020: true, + }, + }, + ], }; diff --git a/new-docs/puppeteer.frame.waitfor.md b/new-docs/puppeteer.frame.waitfor.md index 6e079601739..086554c81b9 100644 --- a/new-docs/puppeteer.frame.waitfor.md +++ b/new-docs/puppeteer.frame.waitfor.md @@ -12,7 +12,7 @@ Signature: ```typescript -waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {}, ...args: SerializableOrJSHandle[]): Promise; +waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: Record, ...args: SerializableOrJSHandle[]): Promise; ``` ## Parameters @@ -20,7 +20,7 @@ waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {}, . | Parameter | Type | Description | | --- | --- | --- | | selectorOrFunctionOrTimeout | string \| number \| Function | a selector, predicate or timeout to wait for. | -| options | {} | optional waiting parameters. | +| options | Record<string, unknown> | optional waiting parameters. | | args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | arguments to pass to pageFunction. | Returns: diff --git a/new-docs/puppeteer.jshandle.jsonvalue.md b/new-docs/puppeteer.jshandle.jsonvalue.md index 2cdac0b4110..7359769add6 100644 --- a/new-docs/puppeteer.jshandle.jsonvalue.md +++ b/new-docs/puppeteer.jshandle.jsonvalue.md @@ -9,11 +9,11 @@ Returns a JSON representation of the object. Signature: ```typescript -jsonValue(): Promise<{}>; +jsonValue(): Promise>; ``` Returns: -Promise<{}> +Promise<Record<string, unknown>> ## Remarks diff --git a/new-docs/puppeteer.puppeteer.launch.md b/new-docs/puppeteer.puppeteer.launch.md index e68a4004afa..a1cd153537a 100644 --- a/new-docs/puppeteer.puppeteer.launch.md +++ b/new-docs/puppeteer.puppeteer.launch.md @@ -11,7 +11,7 @@ Launches puppeteer and launches a browser instance with given arguments and opti ```typescript launch(options?: LaunchOptions & ChromeArgOptions & BrowserOptions & { product?: string; - extraPrefsFirefox?: {}; + extraPrefsFirefox?: Record; }): Promise; ``` @@ -19,7 +19,7 @@ launch(options?: LaunchOptions & ChromeArgOptions & BrowserOptions & { | Parameter | Type | Description | | --- | --- | --- | -| options | [LaunchOptions](./puppeteer.launchoptions.md) & [ChromeArgOptions](./puppeteer.chromeargoptions.md) & [BrowserOptions](./puppeteer.browseroptions.md) & { product?: string; extraPrefsFirefox?: {}; } | Set of configurable options to set on the browser. | +| options | [LaunchOptions](./puppeteer.launchoptions.md) & [ChromeArgOptions](./puppeteer.chromeargoptions.md) & [BrowserOptions](./puppeteer.browseroptions.md) & { product?: string; extraPrefsFirefox?: Record<string, unknown>; } | Set of configurable options to set on the browser. | Returns: diff --git a/package.json b/package.json index 5448ba19b33..150cb49d305 100644 --- a/package.json +++ b/package.json @@ -73,18 +73,18 @@ "@types/sinon": "^9.0.4", "@types/tar-fs": "^1.16.2", "@types/ws": "^7.2.4", - "@typescript-eslint/eslint-plugin": "^2.28.0", - "@typescript-eslint/parser": "^2.28.0", + "@typescript-eslint/eslint-plugin": "^4.4.0", + "@typescript-eslint/parser": "^4.4.0", "@web/test-runner": "^0.8.4", "commonmark": "^0.28.1", "cross-env": "^7.0.2", "dependency-cruiser": "^9.7.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.11.0", + "eslint": "^7.10.0", + "eslint-config-prettier": "^6.12.0", "eslint-plugin-import": "^2.22.0", - "eslint-plugin-mocha": "^6.3.0", - "eslint-plugin-prettier": "^3.1.3", - "eslint-plugin-unicorn": "^19.0.1", + "eslint-plugin-mocha": "^8.0.0", + "eslint-plugin-prettier": "^3.1.4", + "eslint-plugin-unicorn": "^22.0.0", "esprima": "^4.0.0", "expect": "^25.2.7", "husky": "^4.3.0", @@ -95,7 +95,7 @@ "ncp": "^2.0.0", "pixelmatch": "^4.0.2", "pngjs": "^5.0.0", - "prettier": "^2.0.5", + "prettier": "^2.1.2", "sinon": "^9.0.2", "text-diff": "^1.0.1", "ts-node": "^9.0.0", diff --git a/src/.eslintrc.js b/src/.eslintrc.js index 1d9df6e7f93..4ebb9bb1ec5 100644 --- a/src/.eslintrc.js +++ b/src/.eslintrc.js @@ -1,16 +1,19 @@ module.exports = { - "extends": "../.eslintrc.js", - /** - * ESLint rules - * - * All available rules: http://eslint.org/docs/rules/ - * - * Rules take the following form: - * "rule-name", [severity, { opts }] - * Severity: 2 == error, 1 == warning, 0 == off. - */ - "rules": { - "no-console": [2, { "allow": ["warn", "error", "assert", "timeStamp", "time", "timeEnd"] }], - "no-debugger": 0, - } + extends: '../.eslintrc.js', + /** + * ESLint rules + * + * All available rules: http://eslint.org/docs/rules/ + * + * Rules take the following form: + * "rule-name", [severity, { opts }] + * Severity: 2 == error, 1 == warning, 0 == off. + */ + rules: { + 'no-console': [ + 2, + { allow: ['warn', 'error', 'assert', 'timeStamp', 'time', 'timeEnd'] }, + ], + 'no-debugger': 0, + }, }; diff --git a/src/common/Connection.ts b/src/common/Connection.ts index fc2d3607286..d1383157fa8 100644 --- a/src/common/Connection.ts +++ b/src/common/Connection.ts @@ -95,11 +95,13 @@ export class Connection extends EventEmitter { }); } - _rawSend(message: {}): number { + _rawSend(message: Record): number { const id = ++this._lastId; - message = JSON.stringify(Object.assign({}, message, { id })); - debugProtocolSend(message); - this._transport.send(message); + const stringifiedMessage = JSON.stringify( + Object.assign({}, message, { id }) + ); + debugProtocolSend(stringifiedMessage); + this._transport.send(stringifiedMessage); return id; } @@ -182,7 +184,7 @@ export class Connection extends EventEmitter { interface CDPSessionOnMessageObject { id?: number; method: string; - params: {}; + params: Record; error: { message: string; data: any }; result?: any; } diff --git a/src/common/FrameManager.ts b/src/common/FrameManager.ts index 6d35dd6dc1e..e1017487d35 100644 --- a/src/common/FrameManager.ts +++ b/src/common/FrameManager.ts @@ -119,7 +119,7 @@ export class FrameManager extends EventEmitter { } async initialize(): Promise { - const result = await Promise.all<{}, Protocol.Page.GetFrameTreeResponse>([ + const result = await Promise.all([ this._client.send('Page.enable'), this._client.send('Page.getFrameTree'), ]); @@ -1062,7 +1062,7 @@ export class Frame { */ waitFor( selectorOrFunctionOrTimeout: string | number | Function, - options: {} = {}, + options: Record = {}, ...args: SerializableOrJSHandle[] ): Promise { const xPathPattern = '//'; diff --git a/src/common/JSHandle.ts b/src/common/JSHandle.ts index ebf31517a54..819b3958446 100644 --- a/src/common/JSHandle.ts +++ b/src/common/JSHandle.ts @@ -243,7 +243,7 @@ export class JSHandle { * on the object in page and consequent {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse} in puppeteer. * **NOTE** The method throws if the referenced object is not stringifiable. */ - async jsonValue(): Promise<{}> { + async jsonValue(): Promise> { if (this._remoteObject.objectId) { const response = await this._client.send('Runtime.callFunctionOn', { functionDeclaration: 'function() { return this; }', @@ -378,10 +378,9 @@ export class ElementHandle< element.scrollIntoView({ block: 'center', inline: 'center', - // Chrome still supports behavior: instant but it's not in the spec - // so TS shouts We don't want to make this breaking change in - // Puppeteer yet so we'll ignore the line. - // @ts-ignore + // @ts-expect-error Chrome still supports behavior: instant but + // it's not in the spec so TS shouts We don't want to make this + // breaking change in Puppeteer yet so we'll ignore the line. behavior: 'instant', }); return false; @@ -397,10 +396,9 @@ export class ElementHandle< element.scrollIntoView({ block: 'center', inline: 'center', - // Chrome still supports behavior: instant but it's not in the spec - // so TS shouts We don't want to make this breaking change in - // Puppeteer yet so we'll ignore the line. - // @ts-ignore + // @ts-expect-error Chrome still supports behavior: instant but + // it's not in the spec so TS shouts We don't want to make this + // breaking change in Puppeteer yet so we'll ignore the line. behavior: 'instant', }); } diff --git a/src/common/Puppeteer.ts b/src/common/Puppeteer.ts index 7dc50e3de89..5ab356ed3a3 100644 --- a/src/common/Puppeteer.ts +++ b/src/common/Puppeteer.ts @@ -120,7 +120,10 @@ export class Puppeteer { launch( options: LaunchOptions & ChromeArgOptions & - BrowserOptions & { product?: string; extraPrefsFirefox?: {} } = {} + BrowserOptions & { + product?: string; + extraPrefsFirefox?: Record; + } = {} ): Promise { if (options.product) this._productName = options.product; return this._launcher.launch(options); @@ -296,7 +299,6 @@ export class Puppeteer { * @param queryHandler - The {@link CustomQueryHandler | custom query handler} to * register. */ - // eslint-disable-next-line @typescript-eslint/camelcase __experimental_registerCustomQueryHandler( name: string, queryHandler: CustomQueryHandler @@ -307,7 +309,6 @@ export class Puppeteer { /** * @param name - The name of the query handler to unregistered. */ - // eslint-disable-next-line @typescript-eslint/camelcase __experimental_unregisterCustomQueryHandler(name: string): void { unregisterCustomQueryHandler(name); } @@ -315,7 +316,6 @@ export class Puppeteer { /** * @returns a list with the names of all registered custom query handlers. */ - // eslint-disable-next-line @typescript-eslint/camelcase __experimental_customQueryHandlerNames(): string[] { return customQueryHandlerNames(); } @@ -323,7 +323,6 @@ export class Puppeteer { /** * Clears all registered handlers. */ - // eslint-disable-next-line @typescript-eslint/camelcase __experimental_clearQueryHandlers(): void { clearCustomQueryHandlers(); } diff --git a/test/CDPSession.spec.ts b/test/CDPSession.spec.ts index 7ba02d6f800..2ebf10fd966 100644 --- a/test/CDPSession.spec.ts +++ b/test/CDPSession.spec.ts @@ -97,9 +97,9 @@ describeChromeOnly('Target.createCDPSession', function () { expect(error.message).toContain('ThisCommand.DoesNotExist'); async function theSourceOfTheProblems() { - // This fails in TS as it knows that command does not exist but we want to - // have this tests for our users who consume in JS not TS. - // @ts-expect-error + // @ts-expect-error This fails in TS as it knows that command does not + // exist but we want to have this tests for our users who consume in JS + // not TS. await client.send('ThisCommand.DoesNotExist'); } }); diff --git a/test/elementhandle.spec.ts b/test/elementhandle.spec.ts index 424b71ace2d..edb05e98e50 100644 --- a/test/elementhandle.spec.ts +++ b/test/elementhandle.spec.ts @@ -199,11 +199,10 @@ describe('ElementHandle specs', function () { const { page, server } = getTestState(); await page.goto(server.PREFIX + '/input/button.html'); - const buttonTextNode = await page.evaluateHandle( + const buttonTextNode = await page.evaluateHandle( () => document.querySelector('button').firstChild ); let error = null; - // @ts-expect-error await buttonTextNode.click().catch((error_) => (error = error_)); expect(error.message).toBe('Node is not of type HTMLElement'); }); @@ -322,11 +321,9 @@ describe('ElementHandle specs', function () { it('should throw with invalid query names', () => { try { const { puppeteer } = getTestState(); - puppeteer.__experimental_registerCustomQueryHandler( - '1/2/3', - // @ts-expect-error - () => {} - ); + puppeteer.__experimental_registerCustomQueryHandler('1/2/3', { + queryOne: () => document.querySelector('foo'), + }); throw new Error( 'Custom query handler name was invalid - throw expected' ); diff --git a/test/keyboard.spec.ts b/test/keyboard.spec.ts index 889c97483a0..13a2773dd5d 100644 --- a/test/keyboard.spec.ts +++ b/test/keyboard.spec.ts @@ -333,16 +333,16 @@ describe('Keyboard', function () { const { page } = getTestState(); let error = await page.keyboard - // @ts-expect-error + // @ts-expect-error bad input .press('NotARealKey') .catch((error_) => error_); expect(error.message).toBe('Unknown key: "NotARealKey"'); - // @ts-expect-error + // @ts-expect-error bad input error = await page.keyboard.press('ё').catch((error_) => error_); expect(error && error.message).toBe('Unknown key: "ё"'); - // @ts-expect-error + // @ts-expect-error bad input error = await page.keyboard.press('😊').catch((error_) => error_); expect(error && error.message).toBe('Unknown key: "😊"'); }); diff --git a/test/launcher.spec.ts b/test/launcher.spec.ts index aacf0e1e4b9..32ab3d9b402 100644 --- a/test/launcher.spec.ts +++ b/test/launcher.spec.ts @@ -442,11 +442,8 @@ describe('Launcher specs', function () { after(async () => { const { puppeteer } = getTestState(); - /* launcher is a private property so we don't want our users doing this - * but we need to reset the state fully here for testing different - * browser launchers - */ - // @ts-expect-error + // @ts-expect-error launcher is a private property that users can't + // touch, but for testing purposes we need to reset it. puppeteer._lazyLauncher = undefined; puppeteer._productName = productName; }); diff --git a/test/mocha-utils.ts b/test/mocha-utils.ts index ae14bbc67e9..479d7720592 100644 --- a/test/mocha-utils.ts +++ b/test/mocha-utils.ts @@ -92,8 +92,11 @@ const defaultBrowserOptions = Object.assign( `WARN: running ${product} tests with ${defaultBrowserOptions.executablePath}` ); } else { - // TODO(jackfranklin): declare updateRevision in some form for the Firefox launcher. - // @ts-expect-error + // TODO(jackfranklin): declare updateRevision in some form for the Firefox + // launcher. + // @ts-expect-error _updateRevision is defined on the FF launcher + // but not the Chrome one. The types need tidying so that TS can infer that + // properly and not error here. if (product === 'firefox') await puppeteer._launcher._updateRevision(); const executablePath = puppeteer.executablePath(); if (!fs.existsSync(executablePath)) diff --git a/test/navigation.spec.ts b/test/navigation.spec.ts index 0b367f76fb6..ccf4f5dc6b1 100644 --- a/test/navigation.spec.ts +++ b/test/navigation.spec.ts @@ -193,7 +193,7 @@ describe('navigation', function () { let error = null; await page - // @ts-expect-error + // @ts-expect-error purposefully passing an old option .goto(server.EMPTY_PAGE, { waitUntil: 'networkidle' }) .catch((error_) => (error = error_)); expect(error.message).toContain( diff --git a/test/network.spec.ts b/test/network.spec.ts index f56902fc12c..91a973362e5 100644 --- a/test/network.spec.ts +++ b/test/network.spec.ts @@ -516,7 +516,7 @@ describe('network', function () { let error = null; try { - // @ts-expect-error + // @ts-expect-error purposeful bad input await page.setExtraHTTPHeaders({ foo: 1 }); } catch (error_) { error = error_; diff --git a/test/page.spec.ts b/test/page.spec.ts index d81ce95cfcf..7991a9c75b6 100644 --- a/test/page.spec.ts +++ b/test/page.spec.ts @@ -1169,7 +1169,7 @@ describe('Page', function () { let error = null; try { - // @ts-expect-error + // @ts-expect-error purposefully passing bad options await page.addScriptTag('/injectedfile.js'); } catch (error_) { error = error_; @@ -1298,7 +1298,7 @@ describe('Page', function () { let error = null; try { - // @ts-expect-error + // @ts-expect-error purposefully passing bad input await page.addStyleTag('/injectedstyle.css'); } catch (error_) { error = error_; @@ -1652,7 +1652,7 @@ describe('Page', function () { await page.setContent(''); let error = null; try { - // @ts-expect-error + // @ts-expect-error purposefully passing bad input await page.select('select', 12); } catch (error_) { error = error_; diff --git a/test/waittask.spec.ts b/test/waittask.spec.ts index 36ae164d630..76e4765f381 100644 --- a/test/waittask.spec.ts +++ b/test/waittask.spec.ts @@ -94,7 +94,7 @@ describe('waittask specs', function () { const { page } = getTestState(); let error = null; - // @ts-expect-error + // @ts-expect-error purposefully passing bad type for test await page.waitFor({ foo: 'bar' }).catch((error_) => (error = error_)); expect(error.message).toContain('Unsupported target type'); });