Upgrade Ava to v4
This commit is contained in:
parent
9a40cc5274
commit
ce89f1b611
1153 changed files with 27264 additions and 95308 deletions
337
node_modules/ava/lib/runner.js
generated
vendored
337
node_modules/ava/lib/runner.js
generated
vendored
|
|
@ -1,14 +1,19 @@
|
|||
'use strict';
|
||||
const Emittery = require('emittery');
|
||||
const matcher = require('matcher');
|
||||
const ContextRef = require('./context-ref');
|
||||
const createChain = require('./create-chain');
|
||||
const parseTestArgs = require('./parse-test-args');
|
||||
const snapshotManager = require('./snapshot-manager');
|
||||
const serializeError = require('./serialize-error');
|
||||
const Runnable = require('./test');
|
||||
import process from 'node:process';
|
||||
import {pathToFileURL} from 'node:url';
|
||||
|
||||
class Runner extends Emittery {
|
||||
import Emittery from 'emittery';
|
||||
import {matcher} from 'matcher';
|
||||
|
||||
import ContextRef from './context-ref.js';
|
||||
import createChain from './create-chain.js';
|
||||
import parseTestArgs from './parse-test-args.js';
|
||||
import serializeError from './serialize-error.js';
|
||||
import {load as loadSnapshots, determineSnapshotDir} from './snapshot-manager.js';
|
||||
import Runnable from './test.js';
|
||||
import {waitForReady} from './worker/state.cjs';
|
||||
|
||||
const makeFileURL = file => file.startsWith('file://') ? file : pathToFileURL(file).toString();
|
||||
export default class Runner extends Emittery {
|
||||
constructor(options = {}) {
|
||||
super();
|
||||
|
||||
|
|
@ -18,21 +23,18 @@ class Runner extends Emittery {
|
|||
this.file = options.file;
|
||||
this.checkSelectedByLineNumbers = options.checkSelectedByLineNumbers;
|
||||
this.match = options.match || [];
|
||||
this.powerAssert = undefined; // Assigned later.
|
||||
this.projectDir = options.projectDir;
|
||||
this.recordNewSnapshots = options.recordNewSnapshots === true;
|
||||
this.runOnlyExclusive = options.runOnlyExclusive === true;
|
||||
this.serial = options.serial === true;
|
||||
this.skippingTests = false;
|
||||
this.snapshotDir = options.snapshotDir;
|
||||
this.updateSnapshots = options.updateSnapshots;
|
||||
|
||||
this.activeRunnables = new Set();
|
||||
this.boundCompareTestSnapshot = this.compareTestSnapshot.bind(this);
|
||||
this.skippedSnapshots = false;
|
||||
this.boundSkipSnapshot = this.skipSnapshot.bind(this);
|
||||
this.interrupted = false;
|
||||
this.snapshots = null;
|
||||
|
||||
this.nextTaskIndex = 0;
|
||||
this.tasks = {
|
||||
after: [],
|
||||
|
|
@ -43,9 +45,9 @@ class Runner extends Emittery {
|
|||
beforeEach: [],
|
||||
concurrent: [],
|
||||
serial: [],
|
||||
todo: []
|
||||
todo: [],
|
||||
};
|
||||
this.waitForReady = [];
|
||||
this.waitForReady = waitForReady;
|
||||
|
||||
const uniqueTestTitles = new Set();
|
||||
this.registerUniqueTitle = title => {
|
||||
|
|
@ -57,14 +59,21 @@ class Runner extends Emittery {
|
|||
return true;
|
||||
};
|
||||
|
||||
this.notifyTimeoutUpdate = timeoutMs => {
|
||||
this.emit('stateChange', {
|
||||
type: 'test-timeout-configured',
|
||||
period: timeoutMs,
|
||||
});
|
||||
};
|
||||
|
||||
let hasStarted = false;
|
||||
let scheduledStart = false;
|
||||
const meta = Object.freeze({
|
||||
file: options.file,
|
||||
file: makeFileURL(options.file),
|
||||
get snapshotDirectory() {
|
||||
const {file, snapshotDir: fixedLocation, projectDir} = options;
|
||||
return snapshotManager.determineSnapshotDir({file, fixedLocation, projectDir});
|
||||
}
|
||||
return makeFileURL(determineSnapshotDir({file, fixedLocation, projectDir}));
|
||||
},
|
||||
});
|
||||
this.chain = createChain((metadata, testArgs) => { // eslint-disable-line complexity
|
||||
if (hasStarted) {
|
||||
|
|
@ -81,98 +90,96 @@ class Runner extends Emittery {
|
|||
|
||||
metadata.taskIndex = this.nextTaskIndex++;
|
||||
|
||||
const {args, buildTitle, implementations, rawTitle} = parseTestArgs(testArgs);
|
||||
const {args, implementation, title} = parseTestArgs(testArgs);
|
||||
|
||||
if (this.checkSelectedByLineNumbers) {
|
||||
metadata.selected = this.checkSelectedByLineNumbers();
|
||||
}
|
||||
|
||||
if (metadata.todo) {
|
||||
if (implementations.length > 0) {
|
||||
if (implementation) {
|
||||
throw new TypeError('`todo` tests are not allowed to have an implementation. Use `test.skip()` for tests with an implementation.');
|
||||
}
|
||||
|
||||
if (!rawTitle) { // Either undefined or a string.
|
||||
if (!title.raw) { // Either undefined or a string.
|
||||
throw new TypeError('`todo` tests require a title');
|
||||
}
|
||||
|
||||
if (!this.registerUniqueTitle(rawTitle)) {
|
||||
throw new Error(`Duplicate test title: ${rawTitle}`);
|
||||
if (!this.registerUniqueTitle(title.value)) {
|
||||
throw new Error(`Duplicate test title: ${title.value}`);
|
||||
}
|
||||
|
||||
if (this.match.length > 0) {
|
||||
// --match selects TODO tests.
|
||||
if (matcher([rawTitle], this.match).length === 1) {
|
||||
metadata.exclusive = true;
|
||||
this.runOnlyExclusive = true;
|
||||
}
|
||||
// --match selects TODO tests.
|
||||
if (this.match.length > 0 && matcher(title.value, this.match).length === 1) {
|
||||
metadata.exclusive = true;
|
||||
this.runOnlyExclusive = true;
|
||||
}
|
||||
|
||||
this.tasks.todo.push({title: rawTitle, metadata});
|
||||
this.tasks.todo.push({title: title.value, metadata});
|
||||
this.emit('stateChange', {
|
||||
type: 'declared-test',
|
||||
title: rawTitle,
|
||||
title: title.value,
|
||||
knownFailing: false,
|
||||
todo: true
|
||||
todo: true,
|
||||
});
|
||||
} else {
|
||||
if (implementations.length === 0) {
|
||||
if (!implementation) {
|
||||
throw new TypeError('Expected an implementation. Use `test.todo()` for tests without an implementation.');
|
||||
}
|
||||
|
||||
for (const implementation of implementations) {
|
||||
let {title, isSet, isValid, isEmpty} = buildTitle(implementation);
|
||||
if (Array.isArray(implementation)) {
|
||||
throw new TypeError('AVA 4 no longer supports multiple implementations.');
|
||||
}
|
||||
|
||||
if (isSet && !isValid) {
|
||||
throw new TypeError('Test & hook titles must be strings');
|
||||
}
|
||||
|
||||
if (isEmpty) {
|
||||
if (metadata.type === 'test') {
|
||||
throw new TypeError('Tests must have a title');
|
||||
} else if (metadata.always) {
|
||||
title = `${metadata.type}.always hook`;
|
||||
} else {
|
||||
title = `${metadata.type} hook`;
|
||||
}
|
||||
}
|
||||
|
||||
if (metadata.type === 'test' && !this.registerUniqueTitle(title)) {
|
||||
throw new Error(`Duplicate test title: ${title}`);
|
||||
}
|
||||
|
||||
const task = {
|
||||
title,
|
||||
implementation,
|
||||
args,
|
||||
metadata: {...metadata}
|
||||
};
|
||||
if (title.isSet && !title.isValid) {
|
||||
throw new TypeError('Test & hook titles must be strings');
|
||||
}
|
||||
|
||||
let fallbackTitle = title.value;
|
||||
if (title.isEmpty) {
|
||||
if (metadata.type === 'test') {
|
||||
if (this.match.length > 0) {
|
||||
// --match overrides .only()
|
||||
task.metadata.exclusive = matcher([title], this.match).length === 1;
|
||||
}
|
||||
|
||||
if (task.metadata.skipped) {
|
||||
this.skippingTests = true;
|
||||
}
|
||||
|
||||
if (task.metadata.exclusive) {
|
||||
this.runOnlyExclusive = true;
|
||||
}
|
||||
|
||||
this.tasks[metadata.serial ? 'serial' : 'concurrent'].push(task);
|
||||
this.emit('stateChange', {
|
||||
type: 'declared-test',
|
||||
title,
|
||||
knownFailing: metadata.failing,
|
||||
todo: false
|
||||
});
|
||||
} else if (!metadata.skipped) {
|
||||
this.tasks[metadata.type + (metadata.always ? 'Always' : '')].push(task);
|
||||
throw new TypeError('Tests must have a title');
|
||||
} else if (metadata.always) {
|
||||
fallbackTitle = `${metadata.type}.always hook`;
|
||||
} else {
|
||||
fallbackTitle = `${metadata.type} hook`;
|
||||
}
|
||||
}
|
||||
|
||||
if (metadata.type === 'test' && !this.registerUniqueTitle(title.value)) {
|
||||
throw new Error(`Duplicate test title: ${title.value}`);
|
||||
}
|
||||
|
||||
const task = {
|
||||
title: title.value || fallbackTitle,
|
||||
implementation,
|
||||
args,
|
||||
metadata: {...metadata},
|
||||
};
|
||||
|
||||
if (metadata.type === 'test') {
|
||||
if (this.match.length > 0) {
|
||||
// --match overrides .only()
|
||||
task.metadata.exclusive = matcher(title.value, this.match).length === 1;
|
||||
}
|
||||
|
||||
if (task.metadata.exclusive) {
|
||||
this.runOnlyExclusive = true;
|
||||
}
|
||||
|
||||
this.tasks[metadata.serial ? 'serial' : 'concurrent'].push(task);
|
||||
|
||||
this.snapshots.touch(title.value, metadata.taskIndex);
|
||||
|
||||
this.emit('stateChange', {
|
||||
type: 'declared-test',
|
||||
title: title.value,
|
||||
knownFailing: metadata.failing,
|
||||
todo: false,
|
||||
});
|
||||
} else if (!metadata.skipped) {
|
||||
this.tasks[metadata.type + (metadata.always ? 'Always' : '')].push(task);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
serial: false,
|
||||
|
|
@ -182,54 +189,43 @@ class Runner extends Emittery {
|
|||
failing: false,
|
||||
callback: false,
|
||||
inline: false, // Set for attempt metadata created by `t.try()`
|
||||
always: false
|
||||
always: false,
|
||||
}, meta);
|
||||
}
|
||||
|
||||
compareTestSnapshot(options) {
|
||||
if (!this.snapshots) {
|
||||
this.snapshots = snapshotManager.load({
|
||||
file: this.file,
|
||||
fixedLocation: this.snapshotDir,
|
||||
projectDir: this.projectDir,
|
||||
recordNewSnapshots: this.recordNewSnapshots,
|
||||
updating: this.updateSnapshots && !this.runOnlyExclusive && !this.skippingTests
|
||||
});
|
||||
this.emit('dependency', this.snapshots.snapPath);
|
||||
get snapshots() {
|
||||
if (this._snapshots) {
|
||||
return this._snapshots;
|
||||
}
|
||||
|
||||
// Lazy load not when the runner is instantiated but when snapshots are
|
||||
// needed. This should be after the test file has been loaded and source
|
||||
// maps are available.
|
||||
const snapshots = loadSnapshots({
|
||||
file: this.file,
|
||||
fixedLocation: this.snapshotDir,
|
||||
projectDir: this.projectDir,
|
||||
recordNewSnapshots: this.recordNewSnapshots,
|
||||
updating: this.updateSnapshots,
|
||||
});
|
||||
if (snapshots.snapPath !== undefined) {
|
||||
this.emit('dependency', snapshots.snapPath);
|
||||
}
|
||||
|
||||
this._snapshots = snapshots;
|
||||
return snapshots;
|
||||
}
|
||||
|
||||
compareTestSnapshot(options) {
|
||||
return this.snapshots.compare(options);
|
||||
}
|
||||
|
||||
skipSnapshot() {
|
||||
this.skippedSnapshots = true;
|
||||
skipSnapshot(options) {
|
||||
return this.snapshots.skipSnapshot(options);
|
||||
}
|
||||
|
||||
saveSnapshotState() {
|
||||
if (
|
||||
this.updateSnapshots &&
|
||||
(
|
||||
this.runOnlyExclusive ||
|
||||
this.skippingTests ||
|
||||
this.skippedSnapshots
|
||||
)
|
||||
) {
|
||||
return {cannotSave: true};
|
||||
}
|
||||
|
||||
if (this.snapshots) {
|
||||
return {touchedFiles: this.snapshots.save()};
|
||||
}
|
||||
|
||||
if (this.updateSnapshots) {
|
||||
return {touchedFiles: snapshotManager.cleanSnapshots({
|
||||
file: this.file,
|
||||
fixedLocation: this.snapshotDir,
|
||||
projectDir: this.projectDir
|
||||
})};
|
||||
}
|
||||
|
||||
return {};
|
||||
async saveSnapshotState() {
|
||||
return {touchedFiles: await this.snapshots.save()};
|
||||
}
|
||||
|
||||
onRun(runnable) {
|
||||
|
|
@ -240,16 +236,6 @@ class Runner extends Emittery {
|
|||
this.activeRunnables.delete(runnable);
|
||||
}
|
||||
|
||||
attributeLeakedError(err) {
|
||||
for (const runnable of this.activeRunnables) {
|
||||
if (runnable.attributeLeakedError(err)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
beforeExitHandler() {
|
||||
for (const runnable of this.activeRunnables) {
|
||||
runnable.finishDueToInactivity();
|
||||
|
|
@ -269,25 +255,25 @@ class Runner extends Emittery {
|
|||
};
|
||||
|
||||
let waitForSerial = Promise.resolve();
|
||||
await runnables.reduce((previous, runnable) => { // eslint-disable-line unicorn/no-reduce
|
||||
await runnables.reduce((previous, runnable) => { // eslint-disable-line unicorn/no-array-reduce
|
||||
if (runnable.metadata.serial || this.serial) {
|
||||
waitForSerial = previous.then(() => {
|
||||
waitForSerial = previous.then(() =>
|
||||
// Serial runnables run as long as there was no previous failure, unless
|
||||
// the runnable should always be run.
|
||||
return (allPassed || runnable.metadata.always) && runAndStoreResult(runnable);
|
||||
});
|
||||
(allPassed || runnable.metadata.always) && runAndStoreResult(runnable),
|
||||
);
|
||||
return waitForSerial;
|
||||
}
|
||||
|
||||
return Promise.all([
|
||||
previous,
|
||||
waitForSerial.then(() => {
|
||||
waitForSerial.then(() =>
|
||||
// Concurrent runnables are kicked off after the previous serial
|
||||
// runnables have completed, as long as there was no previous failure
|
||||
// (or if the runnable should always be run). One concurrent runnable's
|
||||
// failure does not prevent the next runnable from running.
|
||||
return (allPassed || runnable.metadata.always) && runAndStoreResult(runnable);
|
||||
})
|
||||
(allPassed || runnable.metadata.always) && runAndStoreResult(runnable),
|
||||
),
|
||||
]);
|
||||
}, waitForSerial);
|
||||
|
||||
|
|
@ -303,22 +289,22 @@ class Runner extends Emittery {
|
|||
return result;
|
||||
}
|
||||
|
||||
async runHooks(tasks, contextRef, {titleSuffix, testPassed, associatedTaskIndex} = {}) {
|
||||
async runHooks(tasks, contextRef, {titleSuffix, testPassed} = {}) {
|
||||
const hooks = tasks.map(task => new Runnable({
|
||||
contextRef,
|
||||
experiments: this.experiments,
|
||||
failWithoutAssertions: false,
|
||||
fn: task.args.length === 0 ?
|
||||
task.implementation :
|
||||
t => task.implementation.apply(null, [t].concat(task.args)),
|
||||
fn: task.args.length === 0
|
||||
? task.implementation
|
||||
: t => Reflect.apply(task.implementation, null, [t, ...task.args]),
|
||||
compareTestSnapshot: this.boundCompareTestSnapshot,
|
||||
skipSnapshot: this.boundSkipSnapshot,
|
||||
updateSnapshots: this.updateSnapshots,
|
||||
metadata: {...task.metadata, associatedTaskIndex},
|
||||
powerAssert: this.powerAssert,
|
||||
metadata: task.metadata,
|
||||
title: `${task.title}${titleSuffix || ''}`,
|
||||
isHook: true,
|
||||
testPassed
|
||||
testPassed,
|
||||
notifyTimeoutUpdate: this.notifyTimeoutUpdate,
|
||||
}));
|
||||
const outcome = await this.runMultiple(hooks, this.serial);
|
||||
for (const result of outcome.storedResults) {
|
||||
|
|
@ -327,7 +313,7 @@ class Runner extends Emittery {
|
|||
type: 'hook-finished',
|
||||
title: result.title,
|
||||
duration: result.duration,
|
||||
logs: result.logs
|
||||
logs: result.logs,
|
||||
});
|
||||
} else {
|
||||
this.emit('stateChange', {
|
||||
|
|
@ -335,7 +321,7 @@ class Runner extends Emittery {
|
|||
title: result.title,
|
||||
err: serializeError('Hook failure', true, result.error),
|
||||
duration: result.duration,
|
||||
logs: result.logs
|
||||
logs: result.logs,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -350,8 +336,7 @@ class Runner extends Emittery {
|
|||
contextRef,
|
||||
{
|
||||
titleSuffix: hookSuffix,
|
||||
associatedTaskIndex: task.metadata.taskIndex
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
let testOk = false;
|
||||
|
|
@ -361,16 +346,16 @@ class Runner extends Emittery {
|
|||
contextRef,
|
||||
experiments: this.experiments,
|
||||
failWithoutAssertions: this.failWithoutAssertions,
|
||||
fn: task.args.length === 0 ?
|
||||
task.implementation :
|
||||
t => task.implementation.apply(null, [t].concat(task.args)),
|
||||
fn: task.args.length === 0
|
||||
? task.implementation
|
||||
: t => Reflect.apply(task.implementation, null, [t, ...task.args]),
|
||||
compareTestSnapshot: this.boundCompareTestSnapshot,
|
||||
skipSnapshot: this.boundSkipSnapshot,
|
||||
updateSnapshots: this.updateSnapshots,
|
||||
metadata: task.metadata,
|
||||
powerAssert: this.powerAssert,
|
||||
title: task.title,
|
||||
registerUniqueTitle: this.registerUniqueTitle
|
||||
registerUniqueTitle: this.registerUniqueTitle,
|
||||
notifyTimeoutUpdate: this.notifyTimeoutUpdate,
|
||||
});
|
||||
|
||||
const result = await this.runSingle(test);
|
||||
|
|
@ -382,7 +367,7 @@ class Runner extends Emittery {
|
|||
title: result.title,
|
||||
duration: result.duration,
|
||||
knownFailing: result.metadata.failing,
|
||||
logs: result.logs
|
||||
logs: result.logs,
|
||||
});
|
||||
|
||||
hooksOk = await this.runHooks(
|
||||
|
|
@ -391,7 +376,6 @@ class Runner extends Emittery {
|
|||
{
|
||||
titleSuffix: hookSuffix,
|
||||
testPassed: testOk,
|
||||
associatedTaskIndex: task.metadata.taskIndex
|
||||
});
|
||||
} else {
|
||||
this.emit('stateChange', {
|
||||
|
|
@ -400,7 +384,7 @@ class Runner extends Emittery {
|
|||
err: serializeError('Test failure', true, result.error, this.file),
|
||||
duration: result.duration,
|
||||
knownFailing: result.metadata.failing,
|
||||
logs: result.logs
|
||||
logs: result.logs,
|
||||
});
|
||||
// Don't run `afterEach` hooks if the test failed.
|
||||
}
|
||||
|
|
@ -412,20 +396,21 @@ class Runner extends Emittery {
|
|||
{
|
||||
titleSuffix: hookSuffix,
|
||||
testPassed: testOk,
|
||||
associatedTaskIndex: task.metadata.taskIndex
|
||||
});
|
||||
return alwaysOk && hooksOk && testOk;
|
||||
}
|
||||
|
||||
async start() {
|
||||
async start() { // eslint-disable-line complexity
|
||||
const concurrentTests = [];
|
||||
const serialTests = [];
|
||||
for (const task of this.tasks.serial) {
|
||||
if (this.runOnlyExclusive && !task.metadata.exclusive) {
|
||||
this.snapshots.skipBlock(task.title, task.metadata.taskIndex);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.checkSelectedByLineNumbers && !task.metadata.selected) {
|
||||
this.snapshots.skipBlock(task.title, task.metadata.taskIndex);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -434,20 +419,24 @@ class Runner extends Emittery {
|
|||
title: task.title,
|
||||
knownFailing: task.metadata.failing,
|
||||
skip: task.metadata.skipped,
|
||||
todo: false
|
||||
todo: false,
|
||||
});
|
||||
|
||||
if (!task.metadata.skipped) {
|
||||
if (task.metadata.skipped) {
|
||||
this.snapshots.skipBlock(task.title, task.metadata.taskIndex);
|
||||
} else {
|
||||
serialTests.push(task);
|
||||
}
|
||||
}
|
||||
|
||||
for (const task of this.tasks.concurrent) {
|
||||
if (this.runOnlyExclusive && !task.metadata.exclusive) {
|
||||
this.snapshots.skipBlock(task.title, task.metadata.taskIndex);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.checkSelectedByLineNumbers && !task.metadata.selected) {
|
||||
this.snapshots.skipBlock(task.title, task.metadata.taskIndex);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -456,15 +445,15 @@ class Runner extends Emittery {
|
|||
title: task.title,
|
||||
knownFailing: task.metadata.failing,
|
||||
skip: task.metadata.skipped,
|
||||
todo: false
|
||||
todo: false,
|
||||
});
|
||||
|
||||
if (!task.metadata.skipped) {
|
||||
if (this.serial) {
|
||||
serialTests.push(task);
|
||||
} else {
|
||||
concurrentTests.push(task);
|
||||
}
|
||||
if (task.metadata.skipped) {
|
||||
this.snapshots.skipBlock(task.title, task.metadata.taskIndex);
|
||||
} else if (this.serial) {
|
||||
serialTests.push(task);
|
||||
} else {
|
||||
concurrentTests.push(task);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -482,7 +471,7 @@ class Runner extends Emittery {
|
|||
title: task.title,
|
||||
knownFailing: false,
|
||||
skip: false,
|
||||
todo: true
|
||||
todo: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -498,13 +487,13 @@ class Runner extends Emittery {
|
|||
|
||||
// Note that the hooks and tests always begin running asynchronously.
|
||||
const beforePromise = this.runHooks(this.tasks.before, contextRef);
|
||||
const serialPromise = beforePromise.then(beforeHooksOk => { // eslint-disable-line promise/prefer-await-to-then
|
||||
const serialPromise = beforePromise.then(beforeHooksOk => {
|
||||
// Don't run tests if a `before` hook failed.
|
||||
if (!beforeHooksOk) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return serialTests.reduce(async (previous, task) => { // eslint-disable-line unicorn/no-reduce
|
||||
return serialTests.reduce(async (previous, task) => { // eslint-disable-line unicorn/no-array-reduce
|
||||
const previousOk = await previous;
|
||||
// Don't start tests after an interrupt.
|
||||
if (this.interrupted) {
|
||||
|
|
@ -520,7 +509,7 @@ class Runner extends Emittery {
|
|||
return this.runTest(task, contextRef.copy());
|
||||
}, true);
|
||||
});
|
||||
const concurrentPromise = Promise.all([beforePromise, serialPromise]).then(async ([beforeHooksOk, serialOk]) => { // eslint-disable-line promise/prefer-await-to-then
|
||||
const concurrentPromise = Promise.all([beforePromise, serialPromise]).then(async ([beforeHooksOk, serialOk]) => {
|
||||
// Don't run tests if a `before` hook failed, or if `failFast` is enabled
|
||||
// and a previous serial test failed.
|
||||
if (!beforeHooksOk || (!serialOk && this.failFast)) {
|
||||
|
|
@ -534,9 +523,7 @@ class Runner extends Emittery {
|
|||
|
||||
// If a concurrent test fails, even if `failFast` is enabled it won't
|
||||
// stop other concurrent tests from running.
|
||||
const allOkays = await Promise.all(concurrentTests.map(task => {
|
||||
return this.runTest(task, contextRef.copy());
|
||||
}));
|
||||
const allOkays = await Promise.all(concurrentTests.map(task => this.runTest(task, contextRef.copy())));
|
||||
return allOkays.every(ok => ok);
|
||||
});
|
||||
|
||||
|
|
@ -563,5 +550,3 @@ class Runner extends Emittery {
|
|||
this.interrupted = true;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Runner;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue