Skip to content

Update dependencies #3384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 0 additions & 100 deletions .xo-config.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion ava.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import process from 'node:process';

const skipWatchMode = process.env.TEST_AVA_SKIP_WATCH_MODE ? ['!test/watch-mode/**'] : [];

export default { // eslint-disable-line import/no-anonymous-default-export
export default { // eslint-disable-line import-x/no-anonymous-default-export
files: ['test/**', '!test/**/{fixtures,helpers}/**', ...skipWatchMode],
watchMode: {
ignoreChanges: ['{coverage,docs,media,test-types,test-tap}/**'],
Expand Down
8 changes: 4 additions & 4 deletions entrypoints/main.d.cts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {TestFn} from '../types/test-fn.cjs';

export * from '../types/assertions.cjs';
export * from '../types/try-fn.cjs';
export * from '../types/test-fn.cjs';
export * from '../types/subscribable.cjs';
export type * from '../types/assertions.cjs';
export type * from '../types/try-fn.cjs';
export type * from '../types/test-fn.cjs';
export type * from '../types/subscribable.cjs';

/** Call to declare a test, or chain to declare hooks or test modifiers */
declare const test: TestFn;
Expand Down
8 changes: 4 additions & 4 deletions entrypoints/main.d.mts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {TestFn} from '../types/test-fn.cjs';

export * from '../types/assertions.cjs';
export * from '../types/try-fn.cjs';
export * from '../types/test-fn.cjs';
export * from '../types/subscribable.cjs';
export type * from '../types/assertions.cjs';
export type * from '../types/try-fn.cjs';
export type * from '../types/test-fn.cjs';
export type * from '../types/subscribable.cjs';

/** Call to declare a test, or chain to declare hooks or test modifiers */
declare const test: TestFn;
Expand Down
16 changes: 9 additions & 7 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,14 @@ export default class Api extends Emittery {
if (typeof testFileSelector === 'function') {
selectedFiles = testFileSelector(testFiles, selectedFiles);
} else if (selectedFiles.length === 0) {
selectedFiles = filter.length === 0 ? testFiles : globs.applyTestFileFilter({
cwd: this.options.projectDir,
filter: filter.map(({pattern}) => pattern),
providers,
testFiles,
});
selectedFiles = filter.length === 0
? testFiles
: globs.applyTestFileFilter({
cwd: this.options.projectDir,
filter: filter.map(({pattern}) => pattern),
providers,
testFiles,
});
}
} catch (error) {
selectedFiles = [];
Expand Down Expand Up @@ -291,7 +293,7 @@ export default class Api extends Emittery {
deregisteredSharedWorkers.push(observeWorkerProcess(worker, runStatus));

pendingWorkers.add(worker);
worker.promise.then(() => {
worker.promise.then(() => { // eslint-disable-line promise/prefer-await-to-then
pendingWorkers.delete(worker);
});
timeoutTrigger.debounce();
Expand Down
4 changes: 2 additions & 2 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ export class Assertions {
// Record the stack before it gets lost in the promise chain.
const assertionStack = getAssertionStack();
// Handle "promise like" objects by casting to a real Promise.
const intermediate = Promise.resolve(promise).then(value => { // eslint-disable-line promise/prefer-await-to-then
const intermediate = Promise.resolve(promise).then(value => { // eslint-disable-line promise/prefer-catch, promise/prefer-await-to-then
throw failPending(new AssertionError(message, {
assertion: 't.throwsAsync()',
assertionStack,
Expand Down Expand Up @@ -592,7 +592,7 @@ export class Assertions {
// Create an error object to record the stack before it gets lost in the promise chain.
const assertionStack = getAssertionStack();
// Handle "promise like" objects by casting to a real Promise.
const intermediate = Promise.resolve(promise).then(noop, error => { // eslint-disable-line promise/prefer-await-to-then
const intermediate = Promise.resolve(promise).then(noop, error => { // eslint-disable-line promise/prefer-catch, promise/prefer-await-to-then
throw failPending(new AssertionError(message, {
assertion: 't.notThrowsAsync()',
assertionStack,
Expand Down
2 changes: 1 addition & 1 deletion lib/chalk.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Chalk} from 'chalk'; // eslint-disable-line unicorn/import-style

let chalk = new Chalk(); // eslint-disable-line import/no-mutable-exports
let chalk = new Chalk(); // eslint-disable-line import-x/no-mutable-exports

export {chalk};

Expand Down
15 changes: 9 additions & 6 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ export default async function loadCli() { // eslint-disable-line complexity
const {argv: {config: configFile}} = yargs(hideBin(process.argv)).help(false).version(false);
const loaded = await loadConfig({configFile});
if (loaded.unsupportedFiles.length > 0) {
console.log(chalk.magenta(
` ${figures.warning} AVA does not support JSON config, ignoring:\n\n ${loaded.unsupportedFiles.join('\n ')}`,
));
console.log(chalk.magenta(` ${figures.warning} AVA does not support JSON config, ignoring:\n\n ${loaded.unsupportedFiles.join('\n ')}`));
}

conf = loaded.config;
Expand Down Expand Up @@ -130,7 +128,8 @@ export default async function loadCli() { // eslint-disable-line complexity
files: [],
host: undefined,
port: undefined,
} : null;
}
: null;

let resetCache = false;
const {argv} = yargs(hideBin(process.argv))
Expand Down Expand Up @@ -165,6 +164,7 @@ export default async function loadCli() { // eslint-disable-line complexity
})
.command('* [<pattern>...]', 'Run tests', yargs => yargs.options(FLAGS).positional('pattern', {
array: true,
// eslint-disable-next-line @stylistic/max-len
describe: 'Select which test files to run. Leave empty if you want AVA to run all test files as per your configuration. Accepts glob patterns, directories that (recursively) contain test files, and file paths optionally suffixed with a colon and comma-separated numbers and/or ranges identifying the 1-based line(s) of specific tests to run',
type: 'string',
}), argv => {
Expand Down Expand Up @@ -192,6 +192,7 @@ export default async function loadCli() { // eslint-disable-line complexity
},
}).positional('pattern', {
demand: true,
// eslint-disable-next-line @stylistic/max-len
describe: 'Glob pattern to select a single test file to debug, optionally suffixed with a colon and comma-separated numbers and/or ranges identifying the 1-based line(s) of specific tests to run',
type: 'string',
}),
Expand All @@ -203,14 +204,16 @@ export default async function loadCli() { // eslint-disable-line complexity
host: argv.host,
port: argv.port,
};
})
},
)
.command(
'reset-cache',
'Delete any temporary files and state kept by AVA, then exit',
yargs => yargs,
() => {
resetCache = true;
})
},
)
.example('$0')
.example('$0 test.js')
.example('$0 test.js:4,7-9')
Expand Down
34 changes: 15 additions & 19 deletions lib/line-numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@ const parseNumber = string => Number.parseInt(string, 10);
const removeAllWhitespace = string => string.replaceAll(/\s/g, '');
const range = (start, end) => Array.from({length: end - start + 1}).fill(start).map((element, index) => element + index);

const parseLineNumbers = suffix => sortNumbersAscending(distinctArray(
suffix.split(',').flatMap(part => {
if (NUMBER_REGEX.test(part)) {
return parseNumber(part);
}
const parseLineNumbers = suffix => sortNumbersAscending(distinctArray(suffix.split(',').flatMap(part => {
if (NUMBER_REGEX.test(part)) {
return parseNumber(part);
}

const {groups: {startGroup, endGroup}} = RANGE_REGEX.exec(part);
const start = parseNumber(startGroup);
const end = parseNumber(endGroup);
const {groups: {startGroup, endGroup}} = RANGE_REGEX.exec(part);
const start = parseNumber(startGroup);
const end = parseNumber(endGroup);

if (start > end) {
return range(end, start);
}
if (start > end) {
return range(end, start);
}

return range(start, end);
}),
));
return range(start, end);
})));

export function splitPatternAndLineNumbers(pattern) {
const parts = pattern.split(DELIMITER);
Expand All @@ -49,9 +47,7 @@ export function splitPatternAndLineNumbers(pattern) {
}

export function getApplicableLineNumbers(normalizedFilePath, filter) {
return sortNumbersAscending(distinctArray(
filter
.filter(({pattern, lineNumbers}) => lineNumbers && picomatch.isMatch(normalizedFilePath, pattern))
.flatMap(({lineNumbers}) => lineNumbers),
));
return sortNumbersAscending(distinctArray(filter
.filter(({pattern, lineNumbers}) => lineNumbers && picomatch.isMatch(normalizedFilePath, pattern))
.flatMap(({lineNumbers}) => lineNumbers)));
}
5 changes: 3 additions & 2 deletions lib/reporters/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ export default class Reporter {

this.lineWriter.writeLine(colors.error(`${figures.cross} Line numbers for ${this.relativeFile(event.testFile)} did not match any tests`));
} else if (!this.failFastEnabled && fileStats.remainingTests > 0) {
// eslint-disable-next-line @stylistic/max-len
this.lineWriter.writeLine(colors.error(`${figures.cross} ${fileStats.remainingTests} ${plur('test', fileStats.remainingTests)} remaining in ${this.relativeFile(event.testFile)}`));
}
}
Expand Down Expand Up @@ -632,6 +633,7 @@ export default class Reporter {
this.lineWriter.writeLine(colors.error(`${figures.cross} Couldn’t find any files to test` + firstLinePostfix));
} else {
const {testFileCount: count} = this.selectionInsights;
// eslint-disable-next-line @stylistic/max-len
this.lineWriter.writeLine(colors.error(`${figures.cross} Based on your configuration, ${count} test ${plur('file was', 'files were', count)} found, but did not match the filters:` + firstLinePostfix));
this.lineWriter.writeLine();
for (const {pattern} of this.selectionInsights.filter) {
Expand Down Expand Up @@ -712,8 +714,7 @@ export default class Reporter {
&& this.stats.failedTests === 0
&& this.stats.passedTests > 0
) {
this.lineWriter.writeLine(colors.pass(`${this.stats.passedTests} ${plur('test', this.stats.passedTests)} passed`) + firstLinePostfix,
);
this.lineWriter.writeLine(colors.pass(`${this.stats.passedTests} ${plur('test', this.stats.passedTests)} passed`) + firstLinePostfix);
firstLinePostfix = '';
}

Expand Down
16 changes: 8 additions & 8 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,23 +254,21 @@ export default class Runner extends Emittery {
let waitForSerial = Promise.resolve();
await runnables.reduce((previous, runnable) => { // eslint-disable-line unicorn/no-array-reduce
if (runnable.metadata.serial || this.serial) {
waitForSerial = previous.then(() =>
waitForSerial = previous.then(() => // eslint-disable-line promise/prefer-await-to-then
// Serial runnables run as long as there was no previous failure, unless
// the runnable should always be run.
(allPassed || runnable.metadata.always) && runAndStoreResult(runnable),
);
(allPassed || runnable.metadata.always) && runAndStoreResult(runnable));
return waitForSerial;
}

return Promise.all([
previous,
waitForSerial.then(() =>
waitForSerial.then(() => // eslint-disable-line promise/prefer-await-to-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.
(allPassed || runnable.metadata.always) && runAndStoreResult(runnable),
),
(allPassed || runnable.metadata.always) && runAndStoreResult(runnable)),
]);
}, waitForSerial);

Expand Down Expand Up @@ -379,7 +377,8 @@ export default class Runner extends Emittery {
{
titleSuffix: hookSuffix,
testPassed: testOk,
});
},
);
} else {
this.emit('stateChange', {
type: 'test-failed',
Expand All @@ -399,7 +398,8 @@ export default class Runner extends Emittery {
{
titleSuffix: hookSuffix,
testPassed: testOk,
});
},
);
return alwaysOk && hooksOk && testOk;
}

Expand Down
Loading