Skip to content

Commit cf0fa4c

Browse files
Update dependencies, rely on Node.js 18, other small changes
* Update dependencies * Rely on Node.js 18 language features * Other small changes * Upgrade to tap@18 * Develop and test with [email protected] * Rebuild lockfile --------- Co-authored-by: Mark Wubben <[email protected]>
1 parent 03a6723 commit cf0fa4c

File tree

33 files changed

+8514
-8187
lines changed

33 files changed

+8514
-8187
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
runs-on: ubuntu-latest
4242
strategy:
4343
matrix:
44-
ts-version: [~5.1]
44+
ts-version: [~5.2]
4545
steps:
4646
- uses: actions/checkout@v3
4747
- uses: actions/setup-node@v3

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.tap
12
/coverage
23
/media/**/node_modules/
34
/node_modules/

.taprc

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
browser: false
2-
coverage: false
1+
disable-coverage: true
2+
allow-empty-coverage: true
33
files:
44
- "test-tap/*.js"
55
- "test-tap/reporters/*.js"
66
- "test-tap/integration/*.js"
7-
flow: false
8-
jsx: false
97
timeout: 300
10-
ts: false

.xo-config.cjs

+3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ module.exports = {
99
'media/**',
1010
'test/config/fixtures/config-errors/test.js',
1111
'test/line-numbers/fixtures/line-numbers.js',
12+
'test/**/fixtures',
1213
'test-tap/fixture/snapshots/test-sourcemaps/build/**',
1314
'test-tap/fixture/report/edgecases/ast-syntax-error.cjs',
15+
'test-types',
1416
'examples/typescript-*/**/*.ts',
1517
],
1618
rules: {
@@ -25,6 +27,7 @@ module.exports = {
2527
],
2628
'import/newline-after-import': 'error',
2729
'unicorn/require-post-message-target-origin': 'off',
30+
'unicorn/prefer-event-target': 'off',
2831
},
2932
overrides: [
3033
{

docs/recipes/endpoint-testing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Since tests run concurrently, it's best to create a fresh server instance at lea
1111
Check out the example below:
1212

1313
```js
14-
import http from 'http';
14+
import http from 'node:http';
1515
import test from 'ava';
1616
import got from 'got';
1717
import listen from 'test-listen';

docs/recipes/typescript.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Translations: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/
44

55
AVA comes bundled with a TypeScript definition file. This allows developers to leverage TypeScript for writing tests.
66

7-
This guide assumes you've already set up TypeScript for your project. Note that AVA's definition expects at least version 5.1.
7+
This guide assumes you've already set up TypeScript for your project. Note that AVA's definition expects at least version 5.2.
88

99
## Enabling AVA's support for TypeScript test files
1010

docs/recipes/when-to-use-plan.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ As stated in the previous example, using the `t.throws()` assertion with `async`
9898
In most cases, it's a bad idea to use any complex branching inside your tests. A notable exception is for tests that are auto-generated (perhaps from a JSON document). Below `t.plan()` is used to ensure the correctness of the JSON input:
9999

100100
```js
101-
import fs from 'fs';
102-
import path from 'path';
101+
import fs from 'node:fs';
102+
import path from 'node:path';
103103

104104
const testData = JSON.parse(fs.readFileSync(new URL('./fixtures/test-definitions.json', import.meta.url)));
105105

lib/line-numbers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const sortNumbersAscending = array => {
1313
};
1414

1515
const parseNumber = string => Number.parseInt(string, 10);
16-
const removeAllWhitespace = string => string.replace(/\s/g, '');
16+
const removeAllWhitespace = string => string.replaceAll(/\s/g, '');
1717
const range = (start, end) => Array.from({length: end - start + 1}).fill(start).map((element, index) => element + index);
1818

1919
const parseLineNumbers = suffix => sortNumbersAscending(distinctArray(

lib/load-config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import process from 'node:process';
44
import url from 'node:url';
55

66
import {isPlainObject} from 'is-plain-object';
7-
import {packageConfig, packageJsonPath} from 'pkg-conf';
7+
import {packageConfig, packageJsonPath} from 'package-config';
88

99
const NO_SUCH_FILE = Symbol('no ava.config.js file');
1010
const MISSING_DEFAULT_EXPORT = Symbol('missing default export');

lib/parse-test-args.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const buildTitle = (raw, implementation, args) => {
22
let value = implementation?.title?.(raw, ...args) ?? raw;
33
const isValid = typeof value === 'string';
44
if (isValid) {
5-
value = value.trim().replace(/\s+/g, ' ');
5+
value = value.trim().replaceAll(/\s+/g, ' ');
66
}
77

88
return {

lib/reporters/default.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export default class Reporter {
338338
// we multiplex stdout and stderr into a single stream. However as
339339
// long as stdStream is different from reportStream users can read
340340
// their original output by redirecting the streams.
341-
if (event.chunk[event.chunk.length - 1] !== 0x0A) {
341+
if (event.chunk.at(-1) !== 0x0A) {
342342
this.reportStream.write(os.EOL);
343343
}
344344

@@ -353,7 +353,7 @@ export default class Reporter {
353353
// we multiplex stdout and stderr into a single stream. However as
354354
// long as stdStream is different from reportStream users can read
355355
// their original output by redirecting the streams.
356-
if (event.chunk[event.chunk.length - 1] !== 0x0A) {
356+
if (event.chunk.at(-1) !== 0x0A) {
357357
this.reportStream.write(os.EOL);
358358
}
359359
}
@@ -648,7 +648,7 @@ export default class Reporter {
648648
this.lineWriter.writeLine();
649649

650650
if (this.failures.length > 0) {
651-
const lastFailure = this.failures[this.failures.length - 1];
651+
const lastFailure = this.failures.at(-1);
652652
for (const event of this.failures) {
653653
this.writeFailure(event);
654654
if (event !== lastFailure) {

lib/reporters/tap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default class TapReporter {
122122
this.reportStream.write(`# ${stripAnsi(title)}${os.EOL}`);
123123
if (evt.logs) {
124124
for (const log of evt.logs) {
125-
const logLines = indentString(log, 4).replace(/^ {4}/gm, '# ');
125+
const logLines = indentString(log, 4).replaceAll(/^ {4}/gm, '# ');
126126
this.reportStream.write(`${logLines}${os.EOL}`);
127127
}
128128
}

lib/slash.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function slash(path) {
3030
return path;
3131
}
3232

33-
return path.replace(/\\/g, '/');
33+
return path.replaceAll('\\', '/');
3434
}
3535

3636
module.exports = slash;

lib/snapshot-manager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function combineEntries({blocks}) {
104104
const combined = new BufferBuilder();
105105

106106
for (const {title, snapshots} of blocks) {
107-
const last = snapshots[snapshots.length - 1];
107+
const last = snapshots.at(-1);
108108
combined.write(`\n\n## ${title}\n\n`);
109109

110110
for (const [index, snapshot] of snapshots.entries()) {

lib/worker/channel.cjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ if (isRunningInChildProcess) {
105105
// Node.js. In order to keep track, explicitly reference before attaching.
106106
handle.ref();
107107

108-
exports.options = selectAvaMessage(handle.channel, 'options').then(message => message.ava.options); // eslint-disable-line unicorn/prefer-top-level-await
109-
exports.peerFailed = selectAvaMessage(handle.channel, 'peer-failed'); // eslint-disable-line unicorn/prefer-top-level-await
108+
exports.options = selectAvaMessage(handle.channel, 'options').then(message => message.ava.options);
109+
exports.peerFailed = selectAvaMessage(handle.channel, 'peer-failed');
110110
exports.send = handle.send.bind(handle);
111111
exports.unref = handle.unref.bind(handle);
112112

license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

0 commit comments

Comments
 (0)