diff --git a/.xo-config.cjs b/.xo-config.cjs index 717d451c3..69b03cc44 100644 --- a/.xo-config.cjs +++ b/.xo-config.cjs @@ -28,69 +28,40 @@ module.exports = { }, overrides: [ { - files: [ - 'index.d.ts', - 'types/*.d.ts', - ], + files: '**/*.d.ts', rules: { 'import/extensions': 'off', }, }, { - files: 'plugin.d.ts', - rules: { - 'node/prefer-global/url': 'off', - }, - }, - { - files: '{test,test-{d,tap}}/**/*.ts', + files: 'examples/**', rules: { - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/no-empty-function': 'off', - '@typescript-eslint/no-unsafe-assignment': 'off', - '@typescript-eslint/no-unsafe-call': 'off', - '@typescript-eslint/no-unsafe-member-access': 'off', - '@typescript-eslint/no-unsafe-return': 'off', - '@typescript-eslint/no-unused-vars': 'off', - '@typescript-eslint/prefer-readonly-parameter-types': 'off', + 'ava/no-only-test': 'off', + 'unicorn/prefer-module': 'off', }, }, { - files: '{test,test-{d,tap}}/**', + // TODO: Update tests. + files: 'test/**', rules: { 'import/no-anonymous-default-export': 'off', - 'node/prefer-global/buffer': 'off', 'node/prefer-global/process': 'off', }, }, { - files: 'test-tap/**', - rules: { - 'promise/prefer-await-to-then': 'off', - 'unicorn/error-message': 'off', - 'unicorn/no-array-reduce': 'off', - 'unicorn/prevent-abbreviations': 'off', - }, - }, - { - files: 'test/macros/fixtures/macros.js', - rules: { - 'ava/no-identical-title': 'off', - }, - }, - { - files: [ - 'examples/**', - 'test/snapshot-*/fixtures/**', - ], + // TODO: Update tests. + files: 'test/snapshot-*/fixtures/**', rules: { 'unicorn/prefer-module': 'off', }, }, { - files: 'examples/**', + // TODO: Update tests. + files: 'test-tap/**', rules: { - 'ava/no-only-test': 'off', + 'import/no-anonymous-default-export': 'off', + 'node/prefer-global/process': 'off', + 'unicorn/error-message': 'off', }, }, ], diff --git a/test-d/context.ts b/test-d/context.ts index b77667dde..81aafe0dd 100644 --- a/test-d/context.ts +++ b/test-d/context.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */ import {expectError, expectType} from 'tsd'; import anyTest, {ExecutionContext, TestFn} from '..'; diff --git a/test-d/implementation-result.ts b/test-d/implementation-result.ts index 9c972cc03..4cbdaeb3e 100644 --- a/test-d/implementation-result.ts +++ b/test-d/implementation-result.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */ import test from '..'; test('return a promise-like', t => ({ diff --git a/test-d/macros.ts b/test-d/macros.ts index 7eb1d0ef4..28e92a860 100644 --- a/test-d/macros.ts +++ b/test-d/macros.ts @@ -1,4 +1,4 @@ -/* eslint-disable no-lone-blocks */ +/* eslint-disable no-lone-blocks, @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */ import {expectType} from 'tsd'; import test, {ExecutionContext} from '..'; diff --git a/test-d/plugin.ts b/test-d/plugin.ts index d24db7b7f..8a4099714 100644 --- a/test-d/plugin.ts +++ b/test-d/plugin.ts @@ -4,6 +4,6 @@ import * as plugin from '../plugin'; // eslint-disable-line import/extensions expectType(plugin.registerSharedWorker({filename: '', supportedProtocols: ['experimental']})); -const factory: plugin.SharedWorker.Factory = ({negotiateProtocol}) => { +const factory: plugin.SharedWorker.Factory = ({negotiateProtocol}) => { // eslint-disable-line @typescript-eslint/no-unused-vars expectType(negotiateProtocol(['experimental'])); }; diff --git a/test-d/throws.ts b/test-d/throws.ts index 2b7b2c145..3e7addb45 100644 --- a/test-d/throws.ts +++ b/test-d/throws.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-empty-function */ import {expectType} from 'tsd'; import test from '..'; diff --git a/test-d/try-commit.ts b/test-d/try-commit.ts index 05c4f87bc..adc7bde69 100644 --- a/test-d/try-commit.ts +++ b/test-d/try-commit.ts @@ -1,6 +1,6 @@ import {expectType} from 'tsd'; -import test, {ExecutionContext, Macro} from '..'; +import test, {ExecutionContext} from '..'; test('attempt', async t => { const attempt = await t.try( diff --git a/test-tap/api.js b/test-tap/api.js index 578fe5c26..83f27f4fa 100644 --- a/test-tap/api.js +++ b/test-tap/api.js @@ -23,12 +23,12 @@ async function apiCreator(options = {}) { return instance; } -const opts = [ +const options = [ {workerThreads: true}, {workerThreads: false}, ]; -for (const opt of opts) { +for (const opt of options) { test(`fail-fast mode - workerThreads: ${opt.workerThreads} - single file & serial`, async t => { const api = await apiCreator({ ...opt, diff --git a/test-tap/assert.js b/test-tap/assert.js index a91baba83..edd817c01 100644 --- a/test-tap/assert.js +++ b/test-tap/assert.js @@ -795,8 +795,8 @@ test('.throws()', gather(t => { // Fails because thrown exception is not an error failsWith(t, () => assertions.throws(() => { - const err = 'foo'; - throw err; + const error = 'foo'; + throw error; }), { assertion: 'throws', message: '', @@ -812,10 +812,10 @@ test('.throws()', gather(t => { // Passes because the correct error is thrown. passes(t, () => { - const err = new Error('foo'); + const error = new Error('foo'); return assertions.throws(() => { - throw err; - }, {is: err}); + throw error; + }, {is: error}); }); // Fails because the thrown value is not an error @@ -828,9 +828,9 @@ test('.throws()', gather(t => { // Fails because the thrown value is not the right one fails(t, () => { - const err = new Error('foo'); + const error = new Error('foo'); return assertions.throws(() => { - throw err; + throw error; }, {is: {}}); }); @@ -841,8 +841,8 @@ test('.throws()', gather(t => { // Fails because the thrown value is not an error fails(t, () => assertions.throws(() => { - const err = {name: 'Bob'}; - throw err; + const error = {name: 'Bob'}; + throw error; }, {name: 'Bob'})); // Fails because the thrown value is not the right one @@ -852,29 +852,29 @@ test('.throws()', gather(t => { // Passes because the correct error is thrown. passes(t, () => assertions.throws(() => { - const err = new TypeError(); - err.code = 'ERR_TEST'; - throw err; + const error = new TypeError(); + error.code = 'ERR_TEST'; + throw error; }, {code: 'ERR_TEST'})); // Passes because the correct error is thrown. passes(t, () => assertions.throws(() => { - const err = new TypeError(); - err.code = 42; - throw err; + const error = new TypeError(); + error.code = 42; + throw error; }, {code: 42})); // Fails because the thrown value is not the right one fails(t, () => assertions.throws(() => { - const err = new TypeError(); - err.code = 'ERR_NOPE'; - throw err; + const error = new TypeError(); + error.code = 'ERR_NOPE'; + throw error; }, {code: 'ERR_TEST'})); fails(t, () => assertions.throws(() => { - const err = new TypeError(); - err.code = 1; - throw err; + const error = new TypeError(); + error.code = 1; + throw error; }, {code: 42})); // Regression test for https://github.com/avajs/ava/issues/1676 diff --git a/test-tap/fixture/snapshots/test-sourcemaps/src/feature/__tests__/test.ts b/test-tap/fixture/snapshots/test-sourcemaps/src/feature/__tests__/test.ts index 859d3890d..a35f134f2 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/src/feature/__tests__/test.ts +++ b/test-tap/fixture/snapshots/test-sourcemaps/src/feature/__tests__/test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import test from '../../../../../../../entrypoints/main.cjs'; test('feature test title', t => { diff --git a/test-tap/fixture/snapshots/test-sourcemaps/src/test.ts b/test-tap/fixture/snapshots/test-sourcemaps/src/test.ts index 17d6155d1..3927a6496 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/src/test.ts +++ b/test-tap/fixture/snapshots/test-sourcemaps/src/test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import test from '../../../../../entrypoints/main.cjs'; test('top level test title', t => { diff --git a/test-tap/fixture/snapshots/test-sourcemaps/src/test/test.ts b/test-tap/fixture/snapshots/test-sourcemaps/src/test/test.ts index d265daf43..b4bff440e 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/src/test/test.ts +++ b/test-tap/fixture/snapshots/test-sourcemaps/src/test/test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import test from '../../../../../../entrypoints/main.cjs'; test('test title', t => { diff --git a/test-tap/helper/cli.js b/test-tap/helper/cli.js index 06f0c8f7e..8731c7a36 100644 --- a/test-tap/helper/cli.js +++ b/test-tap/helper/cli.js @@ -38,10 +38,10 @@ export function execCli(args, options, cb) { child.on('close', (code, signal) => { if (code) { - const err = new Error(`test-worker exited with a non-zero exit code: ${code}`); - err.code = code; - err.signal = signal; - resolve(err); + const error = new Error(`test-worker exited with a non-zero exit code: ${code}`); + error.code = code; + error.signal = signal; + resolve(error); return; } diff --git a/test-tap/helper/tty-stream.js b/test-tap/helper/tty-stream.js index 8c84d3cc6..c19444ec5 100644 --- a/test-tap/helper/tty-stream.js +++ b/test-tap/helper/tty-stream.js @@ -1,3 +1,4 @@ +import {Buffer} from 'node:buffer'; import stream from 'node:stream'; import ansiEscapes from 'ansi-escapes'; @@ -20,7 +21,7 @@ export default class TTYStream extends stream.Writable { this.spinnerActivity = []; } - const string = this.sanitizers.reduce((string_, sanitizer) => sanitizer(string_), chunk.toString('utf8')); + const string = this.sanitizers.reduce((string_, sanitizer) => sanitizer(string_), chunk.toString('utf8')); // eslint-disable-line unicorn/no-array-reduce // Ignore the chunk if it was scrubbed completely. Still count 0-length // chunks. if (string !== '' || chunk.length === 0) { @@ -40,7 +41,7 @@ export default class TTYStream extends stream.Writable { } for (const object of chunks) { - this.chunks.push(Buffer.from(this.sanitizers.reduce((string, sanitizer) => sanitizer(string), object.chunk.toString('utf8')), 'utf8')); + this.chunks.push(Buffer.from(this.sanitizers.reduce((string, sanitizer) => sanitizer(string), object.chunk.toString('utf8')), 'utf8')); // eslint-disable-line unicorn/no-array-reduce } this.chunks.push(TTYStream.SEPARATOR); diff --git a/test-tap/integration/assorted.js b/test-tap/integration/assorted.js index e253fa0a8..f2ec439ea 100644 --- a/test-tap/integration/assorted.js +++ b/test-tap/integration/assorted.js @@ -11,8 +11,8 @@ import {execCli} from '../helper/cli.js'; const __dirname = fileURLToPath(new URL('.', import.meta.url)); test('timeout', t => { - execCli(['long-running.cjs', '-T', '1s'], (err, stdout) => { - t.ok(err); + execCli(['long-running.cjs', '-T', '1s'], (error, stdout) => { + t.ok(error); t.match(stdout, /Timed out/); t.end(); }); @@ -31,32 +31,32 @@ test('timeout', t => { // }); test('include anonymous functions in error reports', t => { - execCli('error-in-anonymous-function.cjs', (err, stdout) => { - t.ok(err); + execCli('error-in-anonymous-function.cjs', (error, stdout) => { + t.ok(error); t.match(stdout, /error-in-anonymous-function\.cjs:4:8/); t.end(); }); }); test('--match works', t => { - execCli(['-m=foo', '-m=bar', '-m=!baz', '-m=t* a* f*', '-m=!t* a* n* f*', 'matcher-skip.cjs'], err => { - t.error(err); + execCli(['-m=foo', '-m=bar', '-m=!baz', '-m=t* a* f*', '-m=!t* a* n* f*', 'matcher-skip.cjs'], error => { + t.error(error); t.end(); }); }); for (const tapFlag of ['--tap', '-t']) { test(`${tapFlag} should produce TAP output`, t => { - execCli([tapFlag, 'test.cjs'], {dirname: 'fixture/watcher'}, err => { - t.ok(!err); + execCli([tapFlag, 'test.cjs'], {dirname: 'fixture/watcher'}, error => { + t.ok(!error); t.end(); }); }); } test('works when no files are found', t => { - execCli([], {dirname: 'fixture/globs/no-files'}, (err, stdout) => { - t.equal(err.code, 1); + execCli([], {dirname: 'fixture/globs/no-files'}, (error, stdout) => { + t.equal(error.code, 1); t.match(stdout, 'Couldn’t find any files to test'); t.end(); }); @@ -71,47 +71,47 @@ test('should warn ava is required without the cli', t => { }); test('tests without assertions do not fail if failWithoutAssertions option is set to false', t => { - execCli([], {dirname: 'fixture/pkg-conf/fail-without-assertions'}, err => { - t.error(err); + execCli([], {dirname: 'fixture/pkg-conf/fail-without-assertions'}, error => { + t.error(error); t.end(); }); }); test('--no-color disables formatting colors', t => { - execCli(['--no-color', 'formatting-color.cjs'], (err, stdout) => { - t.ok(err); + execCli(['--no-color', 'formatting-color.cjs'], (error, stdout) => { + t.ok(error); t.equal(stripAnsi(stdout), stdout); t.end(); }); }); test('--color enables formatting colors', t => { - execCli(['--color', 'formatting-color.cjs'], (err, stdout) => { - t.ok(err); + execCli(['--color', 'formatting-color.cjs'], (error, stdout) => { + t.ok(error); t.not(stripAnsi(stdout), stdout); t.end(); }); }); test('sets NODE_ENV to test when it is not set', t => { - execCli('node-env-test.cjs', {env: {}}, (err, stdout) => { - t.error(err); + execCli('node-env-test.cjs', {env: {}}, (error, stdout) => { + t.error(error); t.match(stdout, /1 test passed/); t.end(); }); }); test('doesn’t set NODE_ENV when it is set', t => { - execCli('node-env-foo.cjs', {env: {NODE_ENV: 'foo'}}, (err, stdout) => { - t.error(err); + execCli('node-env-foo.cjs', {env: {NODE_ENV: 'foo'}}, (error, stdout) => { + t.error(error); t.match(stdout, /1 test passed/); t.end(); }); }); test('additional arguments are forwarded to the worker', t => { - execCli(['worker-argv.cjs', '--serial', '--', '--hello', 'world'], err => { - t.error(err); + execCli(['worker-argv.cjs', '--serial', '--', '--hello', 'world'], error => { + t.error(error); t.end(); }); }); @@ -122,32 +122,32 @@ test('reset-cache resets cache', t => { fs.writeFileSync(path.join(cacheDir, 'file'), ''); t.ok(fs.readdirSync(cacheDir).length > 0); - execCli(['reset-cache'], {dirname: 'fixture/reset-cache'}, err => { - t.error(err); + execCli(['reset-cache'], {dirname: 'fixture/reset-cache'}, error => { + t.error(error); t.ok(fs.readdirSync(cacheDir).length === 0); t.end(); }); }); test('selects .cjs test files', t => { - execCli('cjs.cjs', (err, stdout) => { - t.error(err); + execCli('cjs.cjs', (error, stdout) => { + t.error(error); t.match(stdout, /1 test passed/); t.end(); }); }); test('load .mjs test files', t => { - execCli('mjs.mjs', (err, stdout) => { - t.error(err); + execCli('mjs.mjs', (error, stdout) => { + t.error(error); t.match(stdout, /1 test passed/); t.end(); }); }); test('load .js test files as ESM modules', t => { - execCli('test.js', {dirname: 'fixture/pkg-type-module'}, (err, stdout) => { - t.error(err); + execCli('test.js', {dirname: 'fixture/pkg-type-module'}, (error, stdout) => { + t.error(error); t.match(stdout, /1 test passed/); t.end(); }); diff --git a/test-tap/integration/debug.js b/test-tap/integration/debug.js index ad451a4ae..5f755a0a0 100644 --- a/test-tap/integration/debug.js +++ b/test-tap/integration/debug.js @@ -3,24 +3,24 @@ import {test} from 'tap'; import {execCli} from '../helper/cli.js'; test('bails when using --watch while while debugging', t => { - execCli(['debug', '--watch', 'test.cjs'], {dirname: 'fixture/watcher', env: {AVA_FORCE_CI: 'not-ci'}}, (err, stdout, stderr) => { - t.equal(err.code, 1); + execCli(['debug', '--watch', 'test.cjs'], {dirname: 'fixture/watcher', env: {AVA_FORCE_CI: 'not-ci'}}, (error, stdout, stderr) => { + t.equal(error.code, 1); t.match(stderr, 'Watch mode is not available when debugging.'); t.end(); }); }); test('bails when debugging in CI', t => { - execCli(['debug', 'test.cjs'], {dirname: 'fixture/watcher', env: {AVA_FORCE_CI: 'ci'}}, (err, stdout, stderr) => { - t.equal(err.code, 1); + execCli(['debug', 'test.cjs'], {dirname: 'fixture/watcher', env: {AVA_FORCE_CI: 'ci'}}, (error, stdout, stderr) => { + t.equal(error.code, 1); t.match(stderr, 'Debugging is not available in CI.'); t.end(); }); }); test('bails when --tap reporter is used while debugging', t => { - execCli(['debug', '--tap', 'test.cjs'], {dirname: 'fixture/watcher', env: {AVA_FORCE_CI: 'not-ci'}}, (err, stdout, stderr) => { - t.equal(err.code, 1); + execCli(['debug', '--tap', 'test.cjs'], {dirname: 'fixture/watcher', env: {AVA_FORCE_CI: 'not-ci'}}, (error, stdout, stderr) => { + t.equal(error.code, 1); t.match(stderr, 'The TAP reporter is not available when debugging.'); t.end(); }); diff --git a/test-tap/integration/parallel-runs.js b/test-tap/integration/parallel-runs.js index aaeb8a25b..fe30e38c6 100644 --- a/test-tap/integration/parallel-runs.js +++ b/test-tap/integration/parallel-runs.js @@ -12,7 +12,7 @@ test('correctly distributes more test files than CI_NODE_TOTAL', t => { CI_NODE_INDEX: String(i), CI_NODE_TOTAL: '3', }, - }, err => t.error(err)); + }, error => t.error(error)); } }); @@ -26,7 +26,7 @@ test('correctly distributes less test files than CI_NODE_TOTAL', t => { CI_NODE_INDEX: String(i), CI_NODE_TOTAL: '3', }, - }, err => t.error(err)); + }, error => t.error(error)); } }); @@ -40,6 +40,6 @@ test('fail when there are no files', t => { CI_NODE_INDEX: String(i), CI_NODE_TOTAL: '3', }, - }, err => t.ok(err)); + }, error => t.ok(error)); } }); diff --git a/test-tap/integration/snapshots.js b/test-tap/integration/snapshots.js index c0c51b0a9..21577d3a0 100644 --- a/test-tap/integration/snapshots.js +++ b/test-tap/integration/snapshots.js @@ -1,3 +1,4 @@ +import {Buffer} from 'node:buffer'; import fs from 'node:fs'; import path from 'node:path'; import {fileURLToPath} from 'node:url'; diff --git a/test-tap/integration/stack-traces.js b/test-tap/integration/stack-traces.js index 1ed331392..19858e808 100644 --- a/test-tap/integration/stack-traces.js +++ b/test-tap/integration/stack-traces.js @@ -3,8 +3,8 @@ import {test} from 'tap'; import {execCli} from '../helper/cli.js'; test('`AssertionError` should capture infinity stack trace', t => { - execCli('infinity-stack-trace.cjs', (err, stdout) => { - t.ok(err); + execCli('infinity-stack-trace.cjs', (error, stdout) => { + t.ok(error); t.match(stdout, /c \(.*infinity-stack-trace\.cjs:6:20\)/); t.match(stdout, /b \(.*infinity-stack-trace\.cjs:7:18\)/); t.match(stdout, /a \(.*infinity-stack-trace\.cjs:8:18\)/); diff --git a/test-tap/integration/watcher.js b/test-tap/integration/watcher.js index 9a3b1e583..e54292fbf 100644 --- a/test-tap/integration/watcher.js +++ b/test-tap/integration/watcher.js @@ -13,9 +13,9 @@ const END_MESSAGE = 'Type `r` and press enter to rerun tests\nType `u` and press test('watcher reruns test files upon change', t => { let killed = false; - const child = execCli(['--watch', 'test.cjs'], {dirname: 'fixture/watcher', env: {AVA_FORCE_CI: 'not-ci'}}, err => { + const child = execCli(['--watch', 'test.cjs'], {dirname: 'fixture/watcher', env: {AVA_FORCE_CI: 'not-ci'}}, error => { t.ok(killed); - t.error(err); + t.error(error); t.end(); }); @@ -39,9 +39,9 @@ test('watcher reruns test files upon change', t => { test('watcher reruns test files when source dependencies change', t => { let killed = false; - const child = execCli(['--watch', 'test-1.cjs', 'test-2.cjs'], {dirname: 'fixture/watcher/with-dependencies', env: {AVA_FORCE_CI: 'not-ci'}}, err => { + const child = execCli(['--watch', 'test-1.cjs', 'test-2.cjs'], {dirname: 'fixture/watcher/with-dependencies', env: {AVA_FORCE_CI: 'not-ci'}}, error => { t.ok(killed); - t.error(err); + t.error(error); t.end(); }); @@ -63,9 +63,9 @@ test('watcher reruns test files when source dependencies change', t => { test('watcher does not rerun test files when they write snapshot files', t => { let killed = false; - const child = execCli(['--watch', '--update-snapshots', 'test.cjs'], {dirname: 'fixture/snapshots/watcher-rerun', env: {AVA_FORCE_CI: 'not-ci'}}, err => { + const child = execCli(['--watch', '--update-snapshots', 'test.cjs'], {dirname: 'fixture/snapshots/watcher-rerun', env: {AVA_FORCE_CI: 'not-ci'}}, error => { t.ok(killed); - t.error(err); + t.error(error); t.end(); }); @@ -94,8 +94,8 @@ test('watcher does not rerun test files when they unlink snapshot files', t => { dirname: 'fixture/snapshots/watcher-rerun-unlink', env: {AVA_FORCE_CI: 'not-ci', TEMPLATE: 'true'}, }, - err => { - t.error(err); + error => { + t.error(error); // Run fixture in watch mode; snapshots should be removed, and watcher should not rerun let killed = false; @@ -106,9 +106,9 @@ test('watcher does not rerun test files when they unlink snapshot files', t => { dirname: 'fixture/snapshots/watcher-rerun-unlink', env: {AVA_FORCE_CI: 'not-ci'}, }, - err => { + error => { t.ok(killed); - t.error(err); + t.error(error); t.end(); }, ); @@ -135,9 +135,9 @@ test('watcher does not rerun test files when they unlink snapshot files', t => { test('watcher does not rerun test files when ignored files change', t => { let killed = false; - const child = execCli(['--watch'], {dirname: 'fixture/watcher/ignored-files', env: {AVA_FORCE_CI: 'not-ci'}}, err => { + const child = execCli(['--watch'], {dirname: 'fixture/watcher/ignored-files', env: {AVA_FORCE_CI: 'not-ci'}}, error => { t.ok(killed); - t.error(err); + t.error(error); t.end(); }); @@ -162,9 +162,9 @@ test('watcher does not rerun test files when ignored files change', t => { test('watcher reruns test files when snapshot dependencies change', t => { let killed = false; - const child = execCli(['--watch', '--update-snapshots', 'test.cjs'], {dirname: 'fixture/snapshots/watcher-rerun', env: {AVA_FORCE_CI: 'not-ci'}}, err => { + const child = execCli(['--watch', '--update-snapshots', 'test.cjs'], {dirname: 'fixture/snapshots/watcher-rerun', env: {AVA_FORCE_CI: 'not-ci'}}, error => { t.ok(killed); - t.error(err); + t.error(error); t.end(); }); @@ -210,16 +210,16 @@ test('`"tap": true` config is ignored when --watch is given', t => { }); test('bails when --tap reporter is used while --watch is given', t => { - execCli(['--tap', '--watch', 'test.cjs'], {dirname: 'fixture/watcher', env: {AVA_FORCE_CI: 'not-ci'}}, (err, stdout, stderr) => { - t.equal(err.code, 1); + execCli(['--tap', '--watch', 'test.cjs'], {dirname: 'fixture/watcher', env: {AVA_FORCE_CI: 'not-ci'}}, (error, stdout, stderr) => { + t.equal(error.code, 1); t.match(stderr, 'The TAP reporter is not available when using watch mode.'); t.end(); }); }); test('bails when CI is used while --watch is given', t => { - execCli(['--watch', 'test.cjs'], {dirname: 'fixture/watcher', env: {AVA_FORCE_CI: 'ci'}}, (err, stdout, stderr) => { - t.equal(err.code, 1); + execCli(['--watch', 'test.cjs'], {dirname: 'fixture/watcher', env: {AVA_FORCE_CI: 'ci'}}, (error, stdout, stderr) => { + t.equal(error.code, 1); t.match(stderr, 'Watch mode is not available in CI, as it prevents AVA from terminating.'); t.end(); }); diff --git a/test-tap/reporters/improper-usage-messages.js b/test-tap/reporters/improper-usage-messages.js index 603a4b868..0648db207 100644 --- a/test-tap/reporters/improper-usage-messages.js +++ b/test-tap/reporters/improper-usage-messages.js @@ -3,7 +3,7 @@ import {test} from 'tap'; import improperUsageMessages from '../../lib/reporters/improper-usage-messages.js'; test('results when nothing is applicable', t => { - const err = { + const error = { assertion: 'assertion', improperUsage: { name: 'VersionMismatchError', @@ -13,7 +13,7 @@ test('results when nothing is applicable', t => { }, }; - const actualOutput = improperUsageMessages(err); + const actualOutput = improperUsageMessages(error); t.equal(actualOutput, null); t.end(); diff --git a/test-tap/test.js b/test-tap/test.js index adeb657c0..603a08def 100644 --- a/test-tap/test.js +++ b/test-tap/test.js @@ -97,9 +97,9 @@ test('fails if no assertions are run, unless so planned', t => ava(a => a.plan(0 })); test('wrap non-assertion errors', t => { - const err = new Error(); + const error = new Error(); return ava(() => { - throw err; + throw error; }).run().then(result => { t.equal(result.passed, false); t.equal(result.error.message, 'Error thrown in test'); @@ -123,10 +123,10 @@ test('title returns the test title', t => { }); test('handle non-assertion errors even when planned', t => { - const err = new Error('bar'); + const error = new Error('bar'); return ava(a => { a.plan(1); - throw err; + throw error; }).run().then(result => { t.equal(result.passed, false); t.equal(result.error.name, 'AssertionError'); diff --git a/test/configurable-module-format/fixtures/test.ts b/test/configurable-module-format/fixtures/test.ts index 5ed0f2d0f..d206a854b 100644 --- a/test/configurable-module-format/fixtures/test.ts +++ b/test/configurable-module-format/fixtures/test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call */ const test = require('ava'); // eslint-disable-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, ava/no-ignored-test-files, unicorn/prefer-module test('always passing test', t => { diff --git a/test/helpers/exec.js b/test/helpers/exec.js index 8532ea5d0..cbb2208c9 100644 --- a/test/helpers/exec.js +++ b/test/helpers/exec.js @@ -1,3 +1,4 @@ +import {Buffer} from 'node:buffer'; import path from 'node:path'; import {fileURLToPath} from 'node:url'; diff --git a/test/snapshot-removal/test.js b/test/snapshot-removal/test.js index 6abbb441c..b56a891cd 100644 --- a/test/snapshot-removal/test.js +++ b/test/snapshot-removal/test.js @@ -1,3 +1,4 @@ +import {Buffer} from 'node:buffer'; import {promises as fs} from 'node:fs'; import path from 'node:path'; diff --git a/test/snapshot-workflow/invalid-snapfile.js b/test/snapshot-workflow/invalid-snapfile.js index 500d30bc9..a1abd6956 100644 --- a/test/snapshot-workflow/invalid-snapfile.js +++ b/test/snapshot-workflow/invalid-snapfile.js @@ -1,3 +1,4 @@ +import {Buffer} from 'node:buffer'; import {promises as fs} from 'node:fs'; import path from 'node:path';