Update ava to 4.3.3

The [release notes](https://github.com/avajs/ava/releases/tag/v4.3.3)
mention compatibility with Node 18.8.
This commit is contained in:
Henry Mercer 2022-09-02 18:02:07 +01:00
parent 21530f507f
commit bea5e4b220
160 changed files with 2647 additions and 2263 deletions

View file

@ -61,11 +61,18 @@ function findTest(locations, declaration) {
const range = (start, end) => Array.from({length: end - start + 1}).fill(start).map((element, index) => element + index);
const translate = (sourceMap, pos) => {
if (sourceMap === undefined) {
if (sourceMap === null) {
return pos;
}
const entry = sourceMap.findEntry(pos.line - 1, pos.column); // Source maps are 0-based
// When used with ts-node/register, we've seen entries without original values. Return the
// original position.
if (entry.originalLine === undefined || entry.originalColumn === undefined) {
return pos;
}
return {
line: entry.originalLine + 1, // Readjust for Acorn.
column: entry.originalColumn,
@ -81,7 +88,7 @@ export default function lineNumberSelection({file, lineNumbers = []}) {
let locations = parse(file);
let lookedForSourceMap = false;
let sourceMap;
let sourceMap = null;
return () => {
if (!lookedForSourceMap) {
@ -91,7 +98,13 @@ export default function lineNumberSelection({file, lineNumbers = []}) {
// Source maps are not available before then.
sourceMap = findSourceMap(file);
if (sourceMap !== undefined) {
if (sourceMap === undefined) {
// Prior to Node.js 18.8.0, the value when a source map could not be found was `undefined`.
// This changed to `null` in <https://github.com/nodejs/node/pull/43875>.
sourceMap = null;
}
if (sourceMap !== null) {
locations = locations.map(({start, end}) => ({
start: translate(sourceMap, start),
end: translate(sourceMap, end),