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 = {
|
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 };
|
const { processParams, runnerParams, runnerScript } = message.params as { processParams: ProcessInitParams, runnerParams: any, runnerScript: string };
|
||||||
setTtyParams(process.stdout, processParams.stdoutParams);
|
setTtyParams(process.stdout, processParams.stdoutParams);
|
||||||
setTtyParams(process.stderr, processParams.stderrParams);
|
setTtyParams(process.stderr, processParams.stderrParams);
|
||||||
startProfiling();
|
void startProfiling();
|
||||||
const { create } = require(runnerScript);
|
const { create } = require(runnerScript);
|
||||||
processRunner = create(runnerParams) as ProcessRunner;
|
processRunner = create(runnerParams) as ProcessRunner;
|
||||||
processName = processParams.processName;
|
processName = processParams.processName;
|
||||||
|
|
|
||||||
|
|
@ -68,12 +68,12 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
|
||||||
headless: [({ launchOptions }, use) => use(launchOptions.headless ?? true), { scope: 'worker', option: true }],
|
headless: [({ launchOptions }, use) => use(launchOptions.headless ?? true), { scope: 'worker', option: true }],
|
||||||
channel: [({ launchOptions }, use) => use(launchOptions.channel), { scope: 'worker', option: true }],
|
channel: [({ launchOptions }, use) => use(launchOptions.channel), { scope: 'worker', option: true }],
|
||||||
launchOptions: [{}, { 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),
|
// Usually, when connect options are specified (e.g, in the config or in the environment),
|
||||||
// all launch() calls are turned into connect() calls.
|
// all launch() calls are turned into connect() calls.
|
||||||
// However, when running in "reuse browser" mode and connecting to the reusable server,
|
// However, when running in "reuse browser" mode and connecting to the reusable server,
|
||||||
// only the default "browser" fixture should turn into reused browser.
|
// 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 }],
|
}, { scope: 'worker', option: true }],
|
||||||
screenshot: ['off', { scope: 'worker', option: true }],
|
screenshot: ['off', { scope: 'worker', option: true }],
|
||||||
video: ['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) {
|
override async onEnd(result: FullResult) {
|
||||||
super.onEnd(result);
|
await super.onEnd(result);
|
||||||
this._printAnnotations();
|
this._printAnnotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ export class Dispatcher {
|
||||||
this._checkFinished();
|
this._checkFinished();
|
||||||
|
|
||||||
// 5. We got a free worker - perhaps we can immediately start another job?
|
// 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) {
|
private async _startJobInWorker(index: number, job: TestGroup) {
|
||||||
|
|
@ -184,7 +184,7 @@ export class Dispatcher {
|
||||||
this._workerSlots.push({ busy: false });
|
this._workerSlots.push({ busy: false });
|
||||||
// 2. Schedule enough jobs.
|
// 2. Schedule enough jobs.
|
||||||
for (let i = 0; i < this._workerSlots.length; i++)
|
for (let i = 0; i < this._workerSlots.length; i++)
|
||||||
this._scheduleJob();
|
void this._scheduleJob();
|
||||||
this._checkFinished();
|
this._checkFinished();
|
||||||
// 3. More jobs are scheduled when the worker becomes free, or a new job is added.
|
// 3. More jobs are scheduled when the worker becomes free, or a new job is added.
|
||||||
// 4. Wait for all jobs to finish.
|
// 4. Wait for all jobs to finish.
|
||||||
|
|
@ -330,13 +330,13 @@ export class Dispatcher {
|
||||||
// - no unrecoverable worker error
|
// - no unrecoverable worker error
|
||||||
if (!remaining.length && !failedTestIds.size && !params.fatalErrors.length && !params.skipTestsDueToSetupFailure.length && !params.fatalUnknownTestIds && !params.unexpectedExitError) {
|
if (!remaining.length && !failedTestIds.size && !params.fatalErrors.length && !params.skipTestsDueToSetupFailure.length && !params.fatalUnknownTestIds && !params.unexpectedExitError) {
|
||||||
if (this._isWorkerRedundant(worker))
|
if (this._isWorkerRedundant(worker))
|
||||||
worker.stop();
|
void worker.stop();
|
||||||
doneWithJob();
|
doneWithJob();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When worker encounters error, we will stop it and create a new one.
|
// 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) => {
|
const massSkipTestsFromRemaining = (testIds: Set<string>, errors: TestError[], onlyStartedTests?: boolean) => {
|
||||||
remaining = remaining.filter(test => {
|
remaining = remaining.filter(test => {
|
||||||
|
|
@ -444,7 +444,7 @@ export class Dispatcher {
|
||||||
this._queue.unshift({ ...testGroup, tests: remaining });
|
this._queue.unshift({ ...testGroup, tests: remaining });
|
||||||
this._queuedOrRunningHashCount.set(testGroup.workerHash, this._queuedOrRunningHashCount.get(testGroup.workerHash)! + 1);
|
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?
|
// 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.
|
// This job is over, we just scheduled another one.
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ class UIMode {
|
||||||
const exitPromise = new ManualPromise();
|
const exitPromise = new ManualPromise();
|
||||||
this._page.on('close', () => exitPromise.resolve());
|
this._page.on('close', () => exitPromise.resolve());
|
||||||
let queue = Promise.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;
|
const { method, params }: { method: string, params: any } = data;
|
||||||
if (method === 'exit') {
|
if (method === 'exit') {
|
||||||
exitPromise.resolve();
|
exitPromise.resolve();
|
||||||
|
|
@ -118,7 +118,7 @@ class UIMode {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (method === 'stop') {
|
if (method === 'stop') {
|
||||||
this._stopTests();
|
void this._stopTests();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
queue = queue.then(() => this._queueListOrRun(method, params));
|
queue = queue.then(() => this._queueListOrRun(method, params));
|
||||||
|
|
@ -187,7 +187,7 @@ class UIMode {
|
||||||
await run;
|
await run;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _watchFiles(fileNames: string[]) {
|
private _watchFiles(fileNames: string[]) {
|
||||||
const files = new Set<string>();
|
const files = new Set<string>();
|
||||||
for (const fileName of fileNames) {
|
for (const fileName of fileNames) {
|
||||||
files.add(fileName);
|
files.add(fileName);
|
||||||
|
|
@ -250,7 +250,7 @@ class Watcher {
|
||||||
this._reportEventsIfAny();
|
this._reportEventsIfAny();
|
||||||
|
|
||||||
this._watchedFiles = watchedFiles;
|
this._watchedFiles = watchedFiles;
|
||||||
this._fsWatcher?.close().then(() => {});
|
void this._fsWatcher?.close();
|
||||||
this._fsWatcher = undefined;
|
this._fsWatcher = undefined;
|
||||||
this._collector.length = 0;
|
this._collector.length = 0;
|
||||||
clearTimeout(this._throttleTimer);
|
clearTimeout(this._throttleTimer);
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ export class WorkerMain extends ProcessRunner {
|
||||||
if (!this._fatalErrors.length)
|
if (!this._fatalErrors.length)
|
||||||
this._fatalErrors.push(serializeError(error));
|
this._fatalErrors.push(serializeError(error));
|
||||||
}
|
}
|
||||||
this._stop();
|
void this._stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _loadIfNeeded() {
|
private async _loadIfNeeded() {
|
||||||
|
|
@ -220,14 +220,14 @@ export class WorkerMain extends ProcessRunner {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fatalUnknownTestIds = runPayload.entries.map(e => e.testId);
|
fatalUnknownTestIds = runPayload.entries.map(e => e.testId);
|
||||||
this._stop();
|
void this._stop();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// In theory, we should run above code without any errors.
|
// In theory, we should run above code without any errors.
|
||||||
// However, in the case we screwed up, or loadTestFile failed in the worker
|
// However, in the case we screwed up, or loadTestFile failed in the worker
|
||||||
// but not in the runner, let's do a fatal error.
|
// but not in the runner, let's do a fatal error.
|
||||||
this._fatalErrors.push(serializeError(e));
|
this._fatalErrors.push(serializeError(e));
|
||||||
this._stop();
|
void this._stop();
|
||||||
} finally {
|
} finally {
|
||||||
const donePayload: DonePayload = {
|
const donePayload: DonePayload = {
|
||||||
fatalErrors: this._fatalErrors,
|
fatalErrors: this._fatalErrors,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue