Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: enable no-floating-promises on playwright-test (#23484)
Max Schmitt24ac25212b66
diff --git a/packages/playwright-test/.eslintrc.js b/packages/playwright-test/.eslintrc.jsindex ae8768db65..67c9b6313d 100644--- a/packages/playwright-test/.eslintrc.js+++ b/packages/playwright-test/.eslintrc.js@@ -1,3 +1,15 @@+const path = require('path');+module.exports = {- extends: "../.eslintrc-with-ts-config.js",+ extends: '../.eslintrc.js',+ parser: "@typescript-eslint/parser",+ plugins: ["@typescript-eslint", "notice"],+ parserOptions: {+ ecmaVersion: 9,+ sourceType: "module",+ project: path.join(__dirname, '..', '..', 'tsconfig.json'),+ },+ rules: {+ '@typescript-eslint/no-floating-promises': 'error',+ },};diff --git a/packages/playwright-test/src/common/process.ts b/packages/playwright-test/src/common/process.tsindex 8c84e63e6d..73b70d0171 100644--- a/packages/playwright-test/src/common/process.ts+++ b/packages/playwright-test/src/common/process.ts@@ -60,7 +60,7 @@ process.on('message', async (message: any) => {const { processParams, runnerParams, runnerScript } = message.params as { processParams: ProcessInitParams, runnerParams: any, runnerScript: string };setTtyParams(process.stdout, processParams.stdoutParams);setTtyParams(process.stderr, processParams.stderrParams);- startProfiling();+ void startProfiling();const { create } = require(runnerScript);processRunner = create(runnerParams) as ProcessRunner;processName = processParams.processName;diff --git a/packages/playwright-test/src/index.ts b/packages/playwright-test/src/index.tsindex ad40c2782c..debd1ce0bc 100644--- a/packages/playwright-test/src/index.ts+++ b/packages/playwright-test/src/index.ts@@ -68,12 +68,12 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({headless: [({ launchOptions }, use) => use(launchOptions.headless ?? true), { scope: 'worker', option: true }],channel: [({ launchOptions }, use) => use(launchOptions.channel), { scope: 'worker', option: true }],launchOptions: [{}, { scope: 'worker', option: true }],- connectOptions: [({}, use) => {+ connectOptions: [async ({}, use) => {// Usually, when connect options are specified (e.g, in the config or in the environment),// all launch() calls are turned into connect() calls.// However, when running in "reuse browser" mode and connecting to the reusable server,// only the default "browser" fixture should turn into reused browser.- use(process.env.PW_TEST_REUSE_CONTEXT ? undefined : connectOptionsFromEnv());+ await use(process.env.PW_TEST_REUSE_CONTEXT ? undefined : connectOptionsFromEnv());}, { scope: 'worker', option: true }],screenshot: ['off', { scope: 'worker', option: true }],video: ['off', { scope: 'worker', option: true }],diff --git a/packages/playwright-test/src/reporters/github.ts b/packages/playwright-test/src/reporters/github.tsindex bc1e2a4ea4..802b24fa07 100644--- a/packages/playwright-test/src/reporters/github.ts+++ b/packages/playwright-test/src/reporters/github.ts@@ -64,7 +64,7 @@ export class GitHubReporter extends BaseReporter {}override async onEnd(result: FullResult) {- super.onEnd(result);+ await super.onEnd(result);this._printAnnotations();}diff --git a/packages/playwright-test/src/runner/dispatcher.ts b/packages/playwright-test/src/runner/dispatcher.tsindex 434570914e..a77dec81a3 100644--- a/packages/playwright-test/src/runner/dispatcher.ts+++ b/packages/playwright-test/src/runner/dispatcher.ts@@ -112,7 +112,7 @@ export class Dispatcher {this._checkFinished();// 5. We got a free worker - perhaps we can immediately start another job?- this._scheduleJob();+ void this._scheduleJob();}private async _startJobInWorker(index: number, job: TestGroup) {@@ -184,7 +184,7 @@ export class Dispatcher {this._workerSlots.push({ busy: false });// 2. Schedule enough jobs.for (let i = 0; i < this._workerSlots.length; i++)- this._scheduleJob();+ void this._scheduleJob();this._checkFinished();// 3. More jobs are scheduled when the worker becomes free, or a new job is added.// 4. Wait for all jobs to finish.@@ -330,13 +330,13 @@ export class Dispatcher {// - no unrecoverable worker errorif (!remaining.length && !failedTestIds.size && !params.fatalErrors.length && !params.skipTestsDueToSetupFailure.length && !params.fatalUnknownTestIds && !params.unexpectedExitError) {if (this._isWorkerRedundant(worker))- worker.stop();+ void worker.stop();doneWithJob();return;}// When worker encounters error, we will stop it and create a new one.- worker.stop(true /* didFail */);+ void worker.stop(true /* didFail */);const massSkipTestsFromRemaining = (testIds: Set<string>, errors: TestError[], onlyStartedTests?: boolean) => {remaining = remaining.filter(test => {@@ -444,7 +444,7 @@ export class Dispatcher {this._queue.unshift({ ...testGroup, tests: remaining });this._queuedOrRunningHashCount.set(testGroup.workerHash, this._queuedOrRunningHashCount.get(testGroup.workerHash)! + 1);// Perhaps we can immediately start the new job if there is a worker available?- this._scheduleJob();+ void this._scheduleJob();}// This job is over, we just scheduled another one.diff --git a/packages/playwright-test/src/runner/uiMode.ts b/packages/playwright-test/src/runner/uiMode.tsindex 4979cb4660..10b7a02a98 100644--- a/packages/playwright-test/src/runner/uiMode.ts+++ b/packages/playwright-test/src/runner/uiMode.ts@@ -96,7 +96,7 @@ class UIMode {const exitPromise = new ManualPromise();this._page.on('close', () => exitPromise.resolve());let queue = Promise.resolve();- this._page.exposeBinding('sendMessage', false, async (source, data) => {+ await this._page.exposeBinding('sendMessage', false, async (source, data) => {const { method, params }: { method: string, params: any } = data;if (method === 'exit') {exitPromise.resolve();@@ -118,7 +118,7 @@ class UIMode {return;}if (method === 'stop') {- this._stopTests();+ void this._stopTests();return;}queue = queue.then(() => this._queueListOrRun(method, params));@@ -187,7 +187,7 @@ class UIMode {await run;}- private async _watchFiles(fileNames: string[]) {+ private _watchFiles(fileNames: string[]) {const files = new Set<string>();for (const fileName of fileNames) {files.add(fileName);@@ -250,7 +250,7 @@ class Watcher {this._reportEventsIfAny();this._watchedFiles = watchedFiles;- this._fsWatcher?.close().then(() => {});+ void this._fsWatcher?.close();this._fsWatcher = undefined;this._collector.length = 0;clearTimeout(this._throttleTimer);diff --git a/packages/playwright-test/src/worker/workerMain.ts b/packages/playwright-test/src/worker/workerMain.tsindex ef761641c6..5ad260ae93 100644--- a/packages/playwright-test/src/worker/workerMain.ts+++ b/packages/playwright-test/src/worker/workerMain.ts@@ -181,7 +181,7 @@ export class WorkerMain extends ProcessRunner {if (!this._fatalErrors.length)this._fatalErrors.push(serializeError(error));}- this._stop();+ void this._stop();}private async _loadIfNeeded() {@@ -220,14 +220,14 @@ export class WorkerMain extends ProcessRunner {}} else {fatalUnknownTestIds = runPayload.entries.map(e => e.testId);- this._stop();+ void this._stop();}} catch (e) {// In theory, we should run above code without any errors.// However, in the case we screwed up, or loadTestFile failed in the worker// but not in the runner, let's do a fatal error.this._fatalErrors.push(serializeError(e));- this._stop();+ void this._stop();} finally {const donePayload: DonePayload = {fatalErrors: this._fatalErrors,