mirror of
https://github.com/microsoft/playwright.git
synced 2024-11-24 14:55:38 +03:00
chore: enable no-floating-promises on playwright-test (#23484)
This commit is contained in:
parent
f15ea35bfb
commit
24ac25212b
@ -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',
|
||||
},
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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 }],
|
||||
|
@ -64,7 +64,7 @@ export class GitHubReporter extends BaseReporter {
|
||||
}
|
||||
|
||||
override async onEnd(result: FullResult) {
|
||||
super.onEnd(result);
|
||||
await super.onEnd(result);
|
||||
this._printAnnotations();
|
||||
}
|
||||
|
||||
|
@ -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 error
|
||||
if (!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.
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user