ava 6.1.0 → 6.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/assert.js CHANGED
@@ -417,6 +417,7 @@ export class Assertions {
417
417
  }
418
418
 
419
419
  let retval;
420
+ let threw = false;
420
421
  let actual = null;
421
422
  try {
422
423
  retval = fn();
@@ -429,10 +430,11 @@ export class Assertions {
429
430
  }));
430
431
  }
431
432
  } catch (error) {
433
+ threw = true;
432
434
  actual = error;
433
435
  }
434
436
 
435
- if (!actual) {
437
+ if (!threw) {
436
438
  throw fail(new AssertionError(message, {
437
439
  assertion: 't.throws()',
438
440
  formattedDetails: [formatWithLabel('Function returned:', retval)],
package/lib/cli.js CHANGED
@@ -381,7 +381,9 @@ export default async function loadCli() { // eslint-disable-line complexity
381
381
 
382
382
  let globs;
383
383
  try {
384
- globs = normalizeGlobs({files: conf.files, ignoredByWatcher: conf.watchMode?.ignoreChanges, extensions, providers});
384
+ globs = normalizeGlobs({
385
+ files: conf.files, ignoredByWatcher: conf.watchMode?.ignoreChanges, extensions, providers,
386
+ });
385
387
  } catch (error) {
386
388
  exit(error.message);
387
389
  }
@@ -11,9 +11,7 @@ function startChain(name, call, defaults) {
11
11
  }
12
12
 
13
13
  function extendChain(previous, name, flag) {
14
- if (!flag) {
15
- flag = name;
16
- }
14
+ flag ||= name;
17
15
 
18
16
  const fn = (...args) => {
19
17
  callWithFlag(previous, flag, args);
@@ -89,7 +87,9 @@ export default function createChain(fn, defaults, meta) {
89
87
  // "todo" tests cannot be chained. Allow todo tests to be flagged as needing
90
88
  // to be serial.
91
89
  root.todo = startChain('test.todo', fn, {...defaults, type: 'test', todo: true});
92
- root.serial.todo = startChain('test.serial.todo', fn, {...defaults, serial: true, type: 'test', todo: true});
90
+ root.serial.todo = startChain('test.serial.todo', fn, {
91
+ ...defaults, serial: true, type: 'test', todo: true,
92
+ });
93
93
 
94
94
  root.macro = options => {
95
95
  if (typeof options === 'function') {
@@ -48,7 +48,9 @@ const resolveGlobs = async (projectDir, overrideExtensions, overrideFiles) => {
48
48
  }
49
49
 
50
50
  const {conf, providers} = await configCache.get(projectDir);
51
- return buildGlobs({conf, providers, projectDir, overrideExtensions, overrideFiles});
51
+ return buildGlobs({
52
+ conf, providers, projectDir, overrideExtensions, overrideFiles,
53
+ });
52
54
  };
53
55
 
54
56
  const data = new Uint8Array(workerData.dataBuffer);
@@ -35,7 +35,7 @@ const loadConfigFile = async ({projectDir, configFile}) => {
35
35
 
36
36
  function resolveConfigFile(configFile) {
37
37
  if (configFile) {
38
- configFile = path.resolve(configFile); // Relative to CWD
38
+ return path.resolve(configFile); // Relative to CWD
39
39
  }
40
40
 
41
41
  return configFile;
@@ -153,7 +153,9 @@ export async function loadConfig({configFile, resolveFrom = process.cwd(), defau
153
153
  }
154
154
  }
155
155
 
156
- const config = {...defaults, nonSemVerExperiments: {}, ...fileConf, ...packageConf, projectDir, configFile};
156
+ const config = {
157
+ ...defaults, nonSemVerExperiments: {}, ...fileConf, ...packageConf, projectDir, configFile,
158
+ };
157
159
 
158
160
  const {nonSemVerExperiments: experiments} = config;
159
161
  if (!isPlainObject(experiments)) {
@@ -238,7 +238,7 @@ try {
238
238
  },
239
239
  });
240
240
  } catch (error) {
241
- fatal = fatal ?? error;
241
+ fatal ??= error;
242
242
  } finally {
243
243
  if (fatal !== undefined) {
244
244
  process.nextTick(() => {
@@ -220,7 +220,9 @@ export function extractCompressedSnapshot(buffer, snapPath) {
220
220
  const compressedOffset = sha256sumOffset + SHA_256_HASH_LENGTH;
221
221
  const compressed = buffer.slice(compressedOffset);
222
222
 
223
- return {version, compressed, sha256sumOffset, compressedOffset};
223
+ return {
224
+ version, compressed, sha256sumOffset, compressedOffset,
225
+ };
224
226
  }
225
227
 
226
228
  function decodeSnapshots(buffer, snapPath) {
@@ -290,11 +292,7 @@ class Manager {
290
292
  }
291
293
 
292
294
  recordSerialized({data, label, belongsTo, index}) {
293
- let block = this.newBlocksByTitle.get(belongsTo);
294
- if (!block) {
295
- block = {snapshots: []};
296
- }
297
-
295
+ const block = this.newBlocksByTitle.get(belongsTo) ?? {snapshots: []};
298
296
  const {snapshots} = block;
299
297
 
300
298
  if (index > snapshots.length) {
@@ -319,7 +317,9 @@ class Manager {
319
317
 
320
318
  return () => { // Must be called in order!
321
319
  this.hasChanges = true;
322
- this.recordSerialized({data, label, belongsTo, index});
320
+ this.recordSerialized({
321
+ data, label, belongsTo, index,
322
+ });
323
323
  };
324
324
  }
325
325
 
@@ -338,11 +338,7 @@ class Manager {
338
338
 
339
339
  skipSnapshot({belongsTo, index, deferRecording}) {
340
340
  const oldBlock = this.oldBlocksByTitle.get(belongsTo);
341
- let snapshot = oldBlock?.snapshots[index];
342
-
343
- if (!snapshot) {
344
- snapshot = {};
345
- }
341
+ const snapshot = oldBlock?.snapshots[index] ?? {};
346
342
 
347
343
  // Retain the label from the old snapshot, so as not to assume that the
348
344
  // snapshot.skip() arguments are well-formed.
package/lib/test.js CHANGED
@@ -2,7 +2,9 @@ import concordance from 'concordance';
2
2
  import isPromise from 'is-promise';
3
3
  import plur from 'plur';
4
4
 
5
- import {AssertionError, Assertions, checkAssertionMessage, getAssertionStack} from './assert.js';
5
+ import {
6
+ AssertionError, Assertions, checkAssertionMessage, getAssertionStack,
7
+ } from './assert.js';
6
8
  import concordanceOptions from './concordance-options.js';
7
9
  import nowAndTimers from './now-and-timers.cjs';
8
10
  import parseTestArgs from './parse-test-args.js';
@@ -277,7 +279,9 @@ export default class Test {
277
279
 
278
280
  const {deferredSnapshotRecordings, error, logs, passed, assertCount, snapshotCount} = await attempt.run();
279
281
  const errors = error ? [error] : [];
280
- return {assertCount, deferredSnapshotRecordings, errors, logs, passed, snapshotCount, startingSnapshotCount};
282
+ return {
283
+ assertCount, deferredSnapshotRecordings, errors, logs, passed, snapshotCount, startingSnapshotCount,
284
+ };
281
285
  };
282
286
 
283
287
  this.assertCount = 0;
package/lib/watcher.js CHANGED
@@ -7,7 +7,9 @@ import {nodeFileTrace} from '@vercel/nft';
7
7
  import createDebug from 'debug';
8
8
 
9
9
  import {chalk} from './chalk.js';
10
- import {applyTestFileFilter, classify, buildIgnoreMatcher, findTests} from './globs.js';
10
+ import {
11
+ applyTestFileFilter, classify, buildIgnoreMatcher, findTests,
12
+ } from './globs.js';
11
13
  import {levels as providerLevels} from './provider-manager.js';
12
14
 
13
15
  const debug = createDebug('ava:watcher');
@@ -34,7 +36,9 @@ export function available(projectDir) {
34
36
 
35
37
  export async function start({api, filter, globs, projectDir, providers, reporter, stdin, signal}) {
36
38
  providers = providers.filter(({level}) => level >= providerLevels.ava6);
37
- for await (const {files, ...runtimeOptions} of plan({api, filter, globs, projectDir, providers, stdin, abortSignal: signal})) {
39
+ for await (const {files, ...runtimeOptions} of plan({
40
+ api, filter, globs, projectDir, providers, stdin, abortSignal: signal,
41
+ })) {
38
42
  await api.run({files, filter, runtimeOptions});
39
43
  reporter.endRun();
40
44
  reporter.lineWriter.writeLine(END_MESSAGE);
@@ -62,7 +66,9 @@ async function * plan({api, filter, globs, projectDir, providers, stdin, abortSi
62
66
  const changeFromPath = path => {
63
67
  const {isTest} = classify(path, cwdAndGlobs);
64
68
  const stats = fileStats(path);
65
- return {path, isTest, exists: stats !== undefined, isFile: stats?.isFile() ?? false};
69
+ return {
70
+ path, isTest, exists: stats !== undefined, isFile: stats?.isFile() ?? false,
71
+ };
66
72
  };
67
73
 
68
74
  // Begin a file trace in the background.
@@ -106,7 +112,8 @@ async function * plan({api, filter, globs, projectDir, providers, stdin, abortSi
106
112
  case 'uncaught-exception':
107
113
  case 'unhandled-rejection':
108
114
  case 'worker-failed': {
109
- failureCounts.set(evt.testFile, 1 + (failureCounts.get(evt.testFile) ?? 0));
115
+ const path = nodePath.relative(projectDir, evt.testFile);
116
+ failureCounts.set(path, 1 + (failureCounts.get(path) ?? 0));
110
117
  break;
111
118
  }
112
119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ava",
3
- "version": "6.1.0",
3
+ "version": "6.1.2",
4
4
  "description": "Node.js test runner that lets you develop with confidence.",
5
5
  "license": "MIT",
6
6
  "repository": "avajs/ava",
@@ -83,9 +83,9 @@
83
83
  "typescript"
84
84
  ],
85
85
  "dependencies": {
86
- "@vercel/nft": "^0.24.4",
87
- "acorn": "^8.11.2",
88
- "acorn-walk": "^8.3.0",
86
+ "@vercel/nft": "^0.26.2",
87
+ "acorn": "^8.11.3",
88
+ "acorn-walk": "^8.3.2",
89
89
  "ansi-styles": "^6.2.1",
90
90
  "arrgv": "^1.0.2",
91
91
  "arrify": "^3.0.0",
@@ -111,11 +111,11 @@
111
111
  "matcher": "^5.0.0",
112
112
  "memoize": "^10.0.0",
113
113
  "ms": "^2.1.3",
114
- "p-map": "^6.0.0",
114
+ "p-map": "^7.0.1",
115
115
  "package-config": "^5.0.0",
116
116
  "picomatch": "^3.0.1",
117
117
  "plur": "^5.1.0",
118
- "pretty-ms": "^8.0.0",
118
+ "pretty-ms": "^9.0.0",
119
119
  "resolve-cwd": "^3.0.0",
120
120
  "stack-utils": "^2.0.6",
121
121
  "strip-ansi": "^7.1.0",
@@ -128,17 +128,17 @@
128
128
  "@ava/test": "github:avajs/test",
129
129
  "@ava/typescript": "^4.1.0",
130
130
  "@sindresorhus/tsconfig": "^5.0.0",
131
- "@types/node": "^20.10.3",
131
+ "@types/node": "^20.11.10",
132
132
  "ansi-escapes": "^6.2.0",
133
- "c8": "^8.0.1",
133
+ "c8": "^9.1.0",
134
134
  "execa": "^8.0.1",
135
135
  "expect": "^29.7.0",
136
136
  "sinon": "^17.0.1",
137
- "tap": "^18.6.1",
137
+ "tap": "^18.7.0",
138
138
  "tempy": "^3.1.0",
139
- "tsd": "^0.29.0",
140
- "typescript": "~5.3.2",
141
- "xo": "^0.56.0",
139
+ "tsd": "^0.30.4",
140
+ "typescript": "~5.3.3",
141
+ "xo": "^0.57.0",
142
142
  "zen-observable": "^0.10.0"
143
143
  },
144
144
  "peerDependencies": {