ava 5.0.0 → 5.0.1

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.
@@ -1,2 +1,12 @@
1
- export {default} from './main.js';
2
- export * from './main.js';
1
+ import type {TestFn} from '../types/test-fn.cjs';
2
+
3
+ export * from '../types/assertions.cjs';
4
+ export * from '../types/try-fn.cjs';
5
+ export * from '../types/test-fn.cjs';
6
+ export * from '../types/subscribable.cjs';
7
+
8
+ /** Call to declare a test, or chain to declare hooks or test modifiers */
9
+ declare const test: TestFn;
10
+
11
+ /** Call to declare a test, or chain to declare hooks or test modifiers */
12
+ export default test;
@@ -1,9 +1,9 @@
1
- import type {TestFn} from '../types/test-fn.js';
1
+ import type {TestFn} from '../types/test-fn.cjs';
2
2
 
3
- export * from '../types/assertions.js';
4
- export * from '../types/try-fn.js';
5
- export * from '../types/test-fn.js';
6
- export * from '../types/subscribable.js';
3
+ export * from '../types/assertions.cjs';
4
+ export * from '../types/try-fn.cjs';
5
+ export * from '../types/test-fn.cjs';
6
+ export * from '../types/subscribable.cjs';
7
7
 
8
8
  /** Call to declare a test, or chain to declare hooks or test modifiers */
9
9
  declare const test: TestFn;
@@ -1 +1,6 @@
1
- export * from './plugin.js'
1
+ import type {SharedWorker} from '../types/shared-worker.cjs';
2
+
3
+ export function registerSharedWorker<Data = unknown>(options: SharedWorker.Plugin.RegistrationOptions<'ava-4', Data>): SharedWorker.Plugin.Protocol<Data>;
4
+ // Add overloads for additional protocols.
5
+
6
+ export type {SharedWorker} from '../types/shared-worker.cjs';
@@ -1,77 +1,6 @@
1
- import type {URL} from 'node:url';
2
-
3
- export namespace SharedWorker {
4
- export type ProtocolIdentifier = 'ava-4';
5
-
6
- export type FactoryOptions = {
7
- negotiateProtocol <Data = unknown>(supported: readonly ['ava-4']): Protocol<Data>;
8
- // Add overloads for additional protocols.
9
- };
10
-
11
- export type Factory = (options: FactoryOptions) => void;
12
-
13
- export type Protocol<Data = unknown> = {
14
- readonly initialData: Data;
15
- readonly protocol: 'ava-4';
16
- broadcast: (data: Data) => BroadcastMessage<Data>;
17
- ready: () => Protocol<Data>;
18
- subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
19
- testWorkers: () => AsyncIterableIterator<TestWorker<Data>>;
20
- };
21
-
22
- export type BroadcastMessage<Data = unknown> = {
23
- readonly id: string;
24
- replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
25
- };
26
-
27
- export type PublishedMessage<Data = unknown> = {
28
- readonly id: string;
29
- replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
30
- };
31
-
32
- export type ReceivedMessage<Data = unknown> = {
33
- readonly data: Data;
34
- readonly id: string;
35
- readonly testWorker: TestWorker;
36
- reply: (data: Data) => PublishedMessage<Data>;
37
- };
38
-
39
- export type TestWorker<Data = unknown> = {
40
- readonly id: string;
41
- readonly file: string;
42
- publish: (data: Data) => PublishedMessage<Data>;
43
- subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
44
- teardown: (fn: (() => Promise<void>) | (() => void)) => () => Promise<void>;
45
- };
46
-
47
- export namespace Plugin {
48
- export type RegistrationOptions<Identifier extends ProtocolIdentifier, Data = unknown> = {
49
- readonly filename: string | URL;
50
- readonly initialData?: Data;
51
- readonly supportedProtocols: readonly Identifier[];
52
- readonly teardown?: () => void;
53
- };
54
-
55
- export type Protocol<Data = unknown> = {
56
- readonly available: Promise<void>;
57
- readonly currentlyAvailable: boolean;
58
- readonly protocol: 'ava-4';
59
- publish: (data: Data) => PublishedMessage<Data>;
60
- subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
61
- };
62
-
63
- export type PublishedMessage<Data = unknown> = {
64
- readonly id: string;
65
- replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
66
- };
67
-
68
- export type ReceivedMessage<Data = unknown> = {
69
- readonly data: Data;
70
- readonly id: string;
71
- reply: (data: Data) => PublishedMessage<Data>;
72
- };
73
- }
74
- }
1
+ import type {SharedWorker} from '../types/shared-worker.cjs';
75
2
 
76
3
  export function registerSharedWorker<Data = unknown>(options: SharedWorker.Plugin.RegistrationOptions<'ava-4', Data>): SharedWorker.Plugin.Protocol<Data>;
77
4
  // Add overloads for additional protocols.
5
+
6
+ export type {SharedWorker} from '../types/shared-worker.cjs';
package/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ // For compatibility with resolution algorithms other than Node16.
2
+
3
+ export * from './entrypoints/main.cjs';
4
+ export {default} from './entrypoints/main.cjs';
package/lib/api.js CHANGED
@@ -16,6 +16,7 @@ import fork from './fork.js';
16
16
  import * as globs from './globs.js';
17
17
  import isCi from './is-ci.js';
18
18
  import {getApplicableLineNumbers} from './line-numbers.js';
19
+ import {setCappedTimeout} from './now-and-timers.cjs';
19
20
  import {observeWorkerProcess} from './plugin-support/shared-workers.js';
20
21
  import RunStatus from './run-status.js';
21
22
  import scheduler from './scheduler.js';
@@ -52,7 +53,7 @@ class TimeoutTrigger {
52
53
 
53
54
  debounce() {
54
55
  if (this.timer === undefined) {
55
- this.timer = setTimeout(() => this.trigger(), this.waitMs);
56
+ this.timer = setCappedTimeout(() => this.trigger(), this.waitMs);
56
57
  } else {
57
58
  this.timer.refresh();
58
59
  }
@@ -3,3 +3,14 @@ const timers = require('timers');
3
3
 
4
4
  Object.assign(exports, timers);
5
5
  exports.now = Date.now;
6
+
7
+ // Any delay larger than this value is ignored by Node.js, with a delay of `1`
8
+ // used instead. See <https://nodejs.org/api/timers.html#settimeoutcallback-delay-args>.
9
+ const MAX_DELAY = (2 ** 31) - 1;
10
+
11
+ function setCappedTimeout(callback, delay) {
12
+ const safeDelay = Math.min(delay, MAX_DELAY);
13
+ return timers.setTimeout(callback, safeDelay);
14
+ }
15
+
16
+ exports.setCappedTimeout = setCappedTimeout;
package/lib/test.js CHANGED
@@ -405,7 +405,7 @@ export default class Test {
405
405
 
406
406
  this.clearTimeout();
407
407
  this.timeoutMs = ms;
408
- this.timeoutTimer = nowAndTimers.setTimeout(() => {
408
+ this.timeoutTimer = nowAndTimers.setCappedTimeout(() => {
409
409
  this.saveFirstError(new Error(message || 'Test timeout exceeded'));
410
410
 
411
411
  if (this.finishDueToTimeout) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ava",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "Node.js test runner that lets you develop with confidence.",
5
5
  "license": "MIT",
6
6
  "repository": "avajs/ava",
@@ -42,7 +42,8 @@
42
42
  "files": [
43
43
  "entrypoints",
44
44
  "lib",
45
- "types"
45
+ "types",
46
+ "*.d.ts"
46
47
  ],
47
48
  "keywords": [
48
49
  "🦄",
@@ -82,7 +83,7 @@
82
83
  "dependencies": {
83
84
  "acorn": "^8.8.0",
84
85
  "acorn-walk": "^8.2.0",
85
- "ansi-styles": "^6.1.0",
86
+ "ansi-styles": "^6.1.1",
86
87
  "arrgv": "^1.0.2",
87
88
  "arrify": "^3.0.0",
88
89
  "callsites": "^4.0.0",
@@ -90,7 +91,7 @@
90
91
  "chalk": "^5.0.1",
91
92
  "chokidar": "^3.5.3",
92
93
  "chunkd": "^2.0.1",
93
- "ci-info": "^3.3.2",
94
+ "ci-info": "^3.4.0",
94
95
  "ci-parallel-vars": "^1.0.1",
95
96
  "clean-yaml-object": "^0.1.0",
96
97
  "cli-truncate": "^3.1.0",
@@ -100,7 +101,7 @@
100
101
  "currently-unhandled": "^0.4.1",
101
102
  "debug": "^4.3.4",
102
103
  "del": "^7.0.0",
103
- "emittery": "^0.13.1",
104
+ "emittery": "^1.0.0",
104
105
  "figures": "^5.0.0",
105
106
  "globby": "^13.1.2",
106
107
  "ignore-by-default": "^2.1.0",
@@ -131,7 +132,7 @@
131
132
  "@ava/typescript": "^3.0.1",
132
133
  "@sindresorhus/tsconfig": "^3.0.1",
133
134
  "@sinonjs/fake-timers": "^9.1.2",
134
- "ansi-escapes": "^5.0.0",
135
+ "ansi-escapes": "^6.0.0",
135
136
  "c8": "^7.12.0",
136
137
  "delay": "^5.0.0",
137
138
  "execa": "^6.1.0",
@@ -143,9 +144,9 @@
143
144
  "temp-write": "^5.0.0",
144
145
  "tempy": "^3.0.0",
145
146
  "touch": "^3.1.0",
146
- "tsd": "^0.22.0",
147
- "typescript": "^4.7.3",
148
- "xo": "^0.52.2",
147
+ "tsd": "^0.24.1",
148
+ "typescript": "^4.8.3",
149
+ "xo": "^0.52.3",
149
150
  "zen-observable": "^0.8.15"
150
151
  },
151
152
  "peerDependencies": {
package/plugin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ // For compatibility with resolution algorithms other than Node16.
2
+
3
+ export * from './entrypoints/plugin.cjs';
File without changes
@@ -0,0 +1,74 @@
1
+ import type {URL} from 'node:url';
2
+
3
+ export namespace SharedWorker {
4
+ export type ProtocolIdentifier = 'ava-4';
5
+
6
+ export type FactoryOptions = {
7
+ negotiateProtocol <Data = unknown>(supported: readonly ['ava-4']): Protocol<Data>;
8
+ // Add overloads for additional protocols.
9
+ };
10
+
11
+ export type Factory = (options: FactoryOptions) => void;
12
+
13
+ export type Protocol<Data = unknown> = {
14
+ readonly initialData: Data;
15
+ readonly protocol: 'ava-4';
16
+ broadcast: (data: Data) => BroadcastMessage<Data>;
17
+ ready: () => Protocol<Data>;
18
+ subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
19
+ testWorkers: () => AsyncIterableIterator<TestWorker<Data>>;
20
+ };
21
+
22
+ export type BroadcastMessage<Data = unknown> = {
23
+ readonly id: string;
24
+ replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
25
+ };
26
+
27
+ export type PublishedMessage<Data = unknown> = {
28
+ readonly id: string;
29
+ replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
30
+ };
31
+
32
+ export type ReceivedMessage<Data = unknown> = {
33
+ readonly data: Data;
34
+ readonly id: string;
35
+ readonly testWorker: TestWorker;
36
+ reply: (data: Data) => PublishedMessage<Data>;
37
+ };
38
+
39
+ export type TestWorker<Data = unknown> = {
40
+ readonly id: string;
41
+ readonly file: string;
42
+ publish: (data: Data) => PublishedMessage<Data>;
43
+ subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
44
+ teardown: (fn: (() => Promise<void>) | (() => void)) => () => Promise<void>;
45
+ };
46
+
47
+ export namespace Plugin {
48
+ export type RegistrationOptions<Identifier extends ProtocolIdentifier, Data = unknown> = {
49
+ readonly filename: string | URL;
50
+ readonly initialData?: Data;
51
+ readonly supportedProtocols: readonly Identifier[];
52
+ readonly teardown?: () => void;
53
+ };
54
+
55
+ export type Protocol<Data = unknown> = {
56
+ readonly available: Promise<void>;
57
+ readonly currentlyAvailable: boolean;
58
+ readonly protocol: 'ava-4';
59
+ publish: (data: Data) => PublishedMessage<Data>;
60
+ subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
61
+ };
62
+
63
+ export type PublishedMessage<Data = unknown> = {
64
+ readonly id: string;
65
+ replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
66
+ };
67
+
68
+ export type ReceivedMessage<Data = unknown> = {
69
+ readonly data: Data;
70
+ readonly id: string;
71
+ reply: (data: Data) => PublishedMessage<Data>;
72
+ };
73
+ }
74
+ }
File without changes
@@ -1,6 +1,6 @@
1
- import type {Assertions} from './assertions.js';
2
- import type {Subscribable} from './subscribable.js';
3
- import type {TryFn} from './try-fn.js';
1
+ import type {Assertions} from './assertions.cjs';
2
+ import type {Subscribable} from './subscribable.cjs';
3
+ import type {TryFn} from './try-fn.cjs';
4
4
 
5
5
  /** The `t` value passed to test & hook implementations. */
6
6
  export type ExecutionContext<Context = unknown> = {
@@ -1,4 +1,4 @@
1
- import type {Implementation} from './test-fn.js';
1
+ import type {Implementation} from './test-fn.cjs';
2
2
 
3
3
  export type CommitDiscardOptions = {
4
4
  /**