ava 3.8.1 → 3.10.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.
@@ -30,7 +30,7 @@ function dumpError(error) {
30
30
  }
31
31
 
32
32
  if (error.values.length > 0) {
33
- object.values = error.values.reduce((acc, value) => {
33
+ object.values = error.values.reduce((acc, value) => { // eslint-disable-line unicorn/no-reduce
34
34
  acc[value.label] = stripAnsi(value.formatted);
35
35
  return acc;
36
36
  }, {});
@@ -158,6 +158,9 @@ class TapReporter {
158
158
  this.writeTest(evt, {passed: false, todo: true, skip: false});
159
159
  }
160
160
 
161
+ break;
162
+ case 'snapshot-error':
163
+ this.writeComment(evt, {title: 'Could not update snapshots'});
161
164
  break;
162
165
  case 'stats':
163
166
  this.stats = evt.stats;
package/lib/runner.js CHANGED
@@ -23,6 +23,7 @@ class Runner extends Emittery {
23
23
  this.recordNewSnapshots = options.recordNewSnapshots === true;
24
24
  this.runOnlyExclusive = options.runOnlyExclusive === true;
25
25
  this.serial = options.serial === true;
26
+ this.skippingTests = false;
26
27
  this.snapshotDir = options.snapshotDir;
27
28
  this.updateSnapshots = options.updateSnapshots;
28
29
 
@@ -147,6 +148,10 @@ class Runner extends Emittery {
147
148
  task.metadata.exclusive = matcher([title], this.match).length === 1;
148
149
  }
149
150
 
151
+ if (task.metadata.skipped) {
152
+ this.skippingTests = true;
153
+ }
154
+
150
155
  if (task.metadata.exclusive) {
151
156
  this.runOnlyExclusive = true;
152
157
  }
@@ -182,7 +187,7 @@ class Runner extends Emittery {
182
187
  fixedLocation: this.snapshotDir,
183
188
  projectDir: this.projectDir,
184
189
  recordNewSnapshots: this.recordNewSnapshots,
185
- updating: this.updateSnapshots
190
+ updating: this.updateSnapshots && !this.runOnlyExclusive && !this.skippingTests
186
191
  });
187
192
  this.emit('dependency', this.snapshots.snapPath);
188
193
  }
@@ -191,8 +196,12 @@ class Runner extends Emittery {
191
196
  }
192
197
 
193
198
  saveSnapshotState() {
199
+ if (this.updateSnapshots && (this.runOnlyExclusive || this.skippingTests)) {
200
+ return {cannotSave: true};
201
+ }
202
+
194
203
  if (this.snapshots) {
195
- return this.snapshots.save();
204
+ return {touchedFiles: this.snapshots.save()};
196
205
  }
197
206
 
198
207
  if (this.updateSnapshots) {
@@ -201,7 +210,7 @@ class Runner extends Emittery {
201
210
  // were skipped. Perhaps emit a warning if this occurs?
202
211
  }
203
212
 
204
- return null;
213
+ return {};
205
214
  }
206
215
 
207
216
  onRun(runnable) {
@@ -241,7 +250,7 @@ class Runner extends Emittery {
241
250
  };
242
251
 
243
252
  let waitForSerial = Promise.resolve();
244
- await runnables.reduce((previous, runnable) => {
253
+ await runnables.reduce((previous, runnable) => { // eslint-disable-line unicorn/no-reduce
245
254
  if (runnable.metadata.serial || this.serial) {
246
255
  waitForSerial = previous.then(() => {
247
256
  // Serial runnables run as long as there was no previous failure, unless
@@ -451,7 +460,7 @@ class Runner extends Emittery {
451
460
  return false;
452
461
  }
453
462
 
454
- return serialTests.reduce(async (previous, task) => {
463
+ return serialTests.reduce(async (previous, task) => { // eslint-disable-line unicorn/no-reduce
455
464
  const previousOk = await previous;
456
465
  // Don't start tests after an interrupt.
457
466
  if (this.interrupted) {
package/lib/test.js CHANGED
@@ -39,7 +39,9 @@ class ExecutionContext extends assert.Assertions {
39
39
  compareWithSnapshot: options => {
40
40
  return test.compareWithSnapshot(options);
41
41
  },
42
- powerAssert: test.powerAssert
42
+ powerAssert: test.powerAssert,
43
+ experiments: test.experiments,
44
+ disableSnapshots: test.isHook === true
43
45
  });
44
46
  testMap.set(this, test);
45
47
 
@@ -64,8 +66,8 @@ class ExecutionContext extends assert.Assertions {
64
66
 
65
67
  this.plan.skip = () => {};
66
68
 
67
- this.timeout = ms => {
68
- test.timeout(ms);
69
+ this.timeout = (ms, message) => {
70
+ test.timeout(ms, message);
69
71
  };
70
72
 
71
73
  this.teardown = callback => {
@@ -73,6 +75,12 @@ class ExecutionContext extends assert.Assertions {
73
75
  };
74
76
 
75
77
  this.try = async (...attemptArgs) => {
78
+ if (test.isHook) {
79
+ const error = new Error('`t.try()` can only be used in tests');
80
+ test.saveFirstError(error);
81
+ throw error;
82
+ }
83
+
76
84
  const {args, buildTitle, implementations, receivedImplementationArray} = parseTestArgs(attemptArgs);
77
85
 
78
86
  if (implementations.length === 0) {
@@ -430,7 +438,14 @@ class Test {
430
438
  this.planError = planError;
431
439
  }
432
440
 
433
- timeout(ms) {
441
+ timeout(ms, message) {
442
+ const result = assert.checkAssertionMessage('timeout', message);
443
+ if (result !== true) {
444
+ this.saveFirstError(result);
445
+ // Allow the timeout to be set even when the message is invalid.
446
+ message = '';
447
+ }
448
+
434
449
  if (this.finishing) {
435
450
  return;
436
451
  }
@@ -438,7 +453,7 @@ class Test {
438
453
  this.clearTimeout();
439
454
  this.timeoutMs = ms;
440
455
  this.timeoutTimer = nowAndTimers.setTimeout(() => {
441
- this.saveFirstError(new Error('Test timeout exceeded'));
456
+ this.saveFirstError(new Error(message || 'Test timeout exceeded'));
442
457
 
443
458
  if (this.finishDueToTimeout) {
444
459
  this.finishDueToTimeout();
@@ -482,7 +497,13 @@ class Test {
482
497
  }
483
498
 
484
499
  async runTeardowns() {
485
- for (const teardown of this.teardowns) {
500
+ const teardowns = [...this.teardowns];
501
+
502
+ if (this.experiments.reverseTeardowns) {
503
+ teardowns.reverse();
504
+ }
505
+
506
+ for (const teardown of teardowns) {
486
507
  try {
487
508
  await teardown(); // eslint-disable-line no-await-in-loop
488
509
  } catch (error) {
@@ -91,8 +91,10 @@ ipc.options.then(async options => {
91
91
 
92
92
  runner.on('finish', () => {
93
93
  try {
94
- const touchedFiles = runner.saveSnapshotState();
95
- if (touchedFiles) {
94
+ const {cannotSave, touchedFiles} = runner.saveSnapshotState();
95
+ if (cannotSave) {
96
+ ipc.send({type: 'snapshot-error'});
97
+ } else if (touchedFiles) {
96
98
  ipc.send({type: 'touched-files', files: touchedFiles});
97
99
  }
98
100
  } catch (error) {
@@ -196,7 +198,7 @@ ipc.options.then(async options => {
196
198
  if (Reflect.has(mod, Symbol.for('esm:package'))) {
197
199
  requireFn = mod(module);
198
200
  }
199
- } catch (_) {}
201
+ } catch {}
200
202
  }
201
203
 
202
204
  // Install dependency tracker after the require configuration has been evaluated
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "ava",
3
- "version": "3.8.1",
4
- "description": "Testing can be a drag. AVA helps you get it done.",
3
+ "version": "3.10.1",
4
+ "description": "Node.js test runner that lets you develop with confidence.",
5
5
  "license": "MIT",
6
6
  "repository": "avajs/ava",
7
7
  "homepage": "https://avajs.dev",
8
8
  "bin": "cli.js",
9
9
  "engines": {
10
- "node": ">=10.18.0 <11 || >=12.14.0 <13 || >=13.5.0 <14 || >=14.0.0"
10
+ "node": ">=10.18.0 <11 || >=12.14.0 <12.17.0 || >=12.17.0 <13 || >=14.0.0"
11
11
  },
12
12
  "scripts": {
13
- "test": "xo && tsd && c8 tap"
13
+ "test": "xo && tsd && c8 --report=none tap && c8 --report=none --no-clean test-ava && c8 report"
14
14
  },
15
15
  "files": [
16
16
  "lib",
@@ -56,37 +56,37 @@
56
56
  ],
57
57
  "dependencies": {
58
58
  "@concordance/react": "^2.0.0",
59
- "acorn": "^7.1.1",
60
- "acorn-walk": "^7.1.1",
59
+ "acorn": "^7.3.1",
60
+ "acorn-walk": "^7.2.0",
61
61
  "ansi-styles": "^4.2.1",
62
62
  "arrgv": "^1.0.2",
63
63
  "arrify": "^2.0.1",
64
64
  "callsites": "^3.1.0",
65
- "chalk": "^4.0.0",
65
+ "chalk": "^4.1.0",
66
66
  "chokidar": "^3.4.0",
67
67
  "chunkd": "^2.0.1",
68
68
  "ci-info": "^2.0.0",
69
- "ci-parallel-vars": "^1.0.0",
69
+ "ci-parallel-vars": "^1.0.1",
70
70
  "clean-yaml-object": "^0.1.0",
71
71
  "cli-cursor": "^3.1.0",
72
72
  "cli-truncate": "^2.1.0",
73
- "code-excerpt": "^2.1.1",
73
+ "code-excerpt": "^3.0.0",
74
74
  "common-path-prefix": "^3.0.0",
75
- "concordance": "^4.0.0",
75
+ "concordance": "^5.0.0",
76
76
  "convert-source-map": "^1.7.0",
77
77
  "currently-unhandled": "^0.4.1",
78
78
  "debug": "^4.1.1",
79
79
  "del": "^5.1.0",
80
- "emittery": "^0.6.0",
80
+ "emittery": "^0.7.0",
81
81
  "equal-length": "^1.0.0",
82
82
  "figures": "^3.2.0",
83
- "globby": "^11.0.0",
84
- "ignore-by-default": "^1.0.0",
83
+ "globby": "^11.0.1",
84
+ "ignore-by-default": "^2.0.0",
85
85
  "import-local": "^3.0.2",
86
86
  "indent-string": "^4.0.0",
87
87
  "is-error": "^2.2.2",
88
- "is-plain-object": "^3.0.0",
89
- "is-promise": "^3.0.0",
88
+ "is-plain-object": "^3.0.1",
89
+ "is-promise": "^4.0.0",
90
90
  "lodash": "^4.17.15",
91
91
  "matcher": "^3.0.0",
92
92
  "md5-hex": "^3.0.1",
@@ -97,44 +97,45 @@
97
97
  "picomatch": "^2.2.2",
98
98
  "pkg-conf": "^3.1.0",
99
99
  "plur": "^4.0.0",
100
- "pretty-ms": "^6.0.1",
100
+ "pretty-ms": "^7.0.0",
101
101
  "read-pkg": "^5.2.0",
102
102
  "resolve-cwd": "^3.0.0",
103
103
  "slash": "^3.0.0",
104
104
  "source-map-support": "^0.5.19",
105
- "stack-utils": "^2.0.1",
105
+ "stack-utils": "^2.0.2",
106
106
  "strip-ansi": "^6.0.0",
107
107
  "supertap": "^1.0.0",
108
108
  "temp-dir": "^2.0.0",
109
109
  "trim-off-newlines": "^1.0.1",
110
110
  "update-notifier": "^4.1.0",
111
111
  "write-file-atomic": "^3.0.3",
112
- "yargs": "^15.3.1"
112
+ "yargs": "^15.4.0"
113
113
  },
114
114
  "devDependencies": {
115
115
  "@ava/babel": "^1.0.1",
116
- "@babel/plugin-proposal-do-expressions": "^7.8.3",
116
+ "@ava/test": "github:avajs/test",
117
+ "@babel/plugin-proposal-do-expressions": "^7.10.4",
117
118
  "@sinonjs/fake-timers": "^6.0.1",
118
119
  "ansi-escapes": "^4.3.1",
119
- "c8": "^7.1.0",
120
+ "c8": "^7.2.0",
120
121
  "delay": "^4.3.0",
121
122
  "esm": "^3.2.25",
122
- "execa": "^4.0.0",
123
+ "execa": "^4.0.2",
123
124
  "get-stream": "^5.1.0",
124
- "p-event": "^4.1.0",
125
+ "p-event": "^4.2.0",
125
126
  "proxyquire": "^2.1.3",
126
127
  "react": "^16.13.1",
127
128
  "react-test-renderer": "^16.13.1",
128
- "replace-string": "^3.0.0",
129
+ "replace-string": "^3.1.0",
129
130
  "sinon": "^9.0.2",
130
131
  "source-map-fixtures": "^2.1.0",
131
132
  "tap": "^14.10.7",
132
133
  "temp-write": "^4.0.0",
133
134
  "tempy": "^0.5.0",
134
135
  "touch": "^3.1.0",
135
- "tsd": "^0.11.0",
136
- "typescript": "^3.8.3",
137
- "xo": "^0.30.0",
136
+ "tsd": "^0.13.1",
137
+ "typescript": "^3.9.6",
138
+ "xo": "^0.32.1",
138
139
  "zen-observable": "^0.8.15"
139
140
  }
140
141
  }
package/readme.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/avajs/ava.svg?branch=master)](https://travis-ci.org/avajs/ava) [![Coverage Status](https://codecov.io/gh/avajs/ava/branch/master/graph/badge.svg)](https://codecov.io/gh/avajs/ava/branch/master) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/ava)
4
4
  [![Mentioned in Awesome Node.js](https://awesome.re/mentioned-badge.svg)](https://github.com/sindresorhus/awesome-nodejs)
5
5
 
6
- Testing can be a drag. AVA helps you get it done. AVA is a test runner for Node.js with a concise API, detailed error output, embrace of new language features and process isolation that let you write tests more effectively. So you can ship more awesome code. 🚀
6
+ AVA is a test runner for Node.js with a concise API, detailed error output, embrace of new language features and process isolation that lets you develop with confidence 🚀
7
7
 
8
8
  Follow the [AVA Twitter account](https://twitter.com/ava__js) for updates.
9
9