ava 1.2.1 → 1.4.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.
package/index.d.ts CHANGED
@@ -29,6 +29,9 @@ export type SnapshotOptions = {
29
29
  };
30
30
 
31
31
  export interface Assertions {
32
+ /** Assert that `actual` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy). Comes with power-assert. */
33
+ assert: AssertAssertion;
34
+
32
35
  /** Assert that `actual` is [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to `expected`. */
33
36
  deepEqual: DeepEqualAssertion;
34
37
 
@@ -96,6 +99,14 @@ export interface Assertions {
96
99
  truthy: TruthyAssertion;
97
100
  }
98
101
 
102
+ export interface AssertAssertion {
103
+ /** Assert that `actual` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy). Comes with power-assert. */
104
+ (actual: any, message?: string): void;
105
+
106
+ /** Skip this assertion. */
107
+ skip(actual: any, message?: string): void;
108
+ }
109
+
99
110
  export interface DeepEqualAssertion {
100
111
  /** Assert that `actual` is [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to `expected`. */
101
112
  <ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void;
package/index.js.flow CHANGED
@@ -42,6 +42,9 @@ export type SnapshotOptions = {
42
42
  };
43
43
 
44
44
  export interface Assertions {
45
+ /** Assert that `actual` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy). Comes with power-assert. */
46
+ assert: AssertAssertion;
47
+
45
48
  /** Assert that `actual` is [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to `expected`. */
46
49
  deepEqual: DeepEqualAssertion;
47
50
 
@@ -109,6 +112,14 @@ export interface Assertions {
109
112
  truthy: TruthyAssertion;
110
113
  }
111
114
 
115
+ export interface AssertAssertion {
116
+ /** Assert that `actual` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy). Comes with power-assert. */
117
+ (actual: any, message?: string): void;
118
+
119
+ /** Skip this assertion. */
120
+ skip(actual: any, message?: string): void;
121
+ }
122
+
112
123
  export interface DeepEqualAssertion {
113
124
  /** Assert that `actual` is [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to `expected`. */
114
125
  (actual: any, expected: any, message?: string): void;
package/lib/assert.js CHANGED
@@ -215,7 +215,7 @@ function assertExpectations({assertion, actual, expectations, message, prefix, s
215
215
  });
216
216
  }
217
217
 
218
- if (typeof expectations.code === 'string' && actual.code !== expectations.code) {
218
+ if (typeof expectations.code !== 'undefined' && actual.code !== expectations.code) {
219
219
  throw new AssertionError({
220
220
  assertion,
221
221
  message,
@@ -589,110 +589,139 @@ function wrapAssertions(callbacks) {
589
589
  message: message || 'No snapshot available, run with --update-snapshots'
590
590
  }));
591
591
  }
592
- }
593
- };
592
+ },
594
593
 
595
- const enhancedAssertions = enhanceAssert(pass, fail, {
596
594
  truthy(actual, message) {
597
- if (!actual) {
598
- throw new AssertionError({
595
+ if (actual) {
596
+ pass(this);
597
+ } else {
598
+ fail(this, new AssertionError({
599
599
  assertion: 'truthy',
600
600
  message,
601
601
  operator: '!!',
602
602
  values: [formatWithLabel('Value is not truthy:', actual)]
603
- });
603
+ }));
604
604
  }
605
605
  },
606
606
 
607
607
  falsy(actual, message) {
608
608
  if (actual) {
609
- throw new AssertionError({
609
+ fail(this, new AssertionError({
610
610
  assertion: 'falsy',
611
611
  message,
612
612
  operator: '!',
613
613
  values: [formatWithLabel('Value is not falsy:', actual)]
614
- });
614
+ }));
615
+ } else {
616
+ pass(this);
615
617
  }
616
618
  },
617
619
 
618
620
  true(actual, message) {
619
- if (actual !== true) {
620
- throw new AssertionError({
621
+ if (actual === true) {
622
+ pass(this);
623
+ } else {
624
+ fail(this, new AssertionError({
621
625
  assertion: 'true',
622
626
  message,
623
627
  values: [formatWithLabel('Value is not `true`:', actual)]
624
- });
628
+ }));
625
629
  }
626
630
  },
627
631
 
628
632
  false(actual, message) {
629
- if (actual !== false) {
630
- throw new AssertionError({
633
+ if (actual === false) {
634
+ pass(this);
635
+ } else {
636
+ fail(this, new AssertionError({
631
637
  assertion: 'false',
632
638
  message,
633
639
  values: [formatWithLabel('Value is not `false`:', actual)]
634
- });
640
+ }));
635
641
  }
636
642
  },
637
643
 
638
644
  regex(string, regex, message) {
639
645
  if (typeof string !== 'string') {
640
- throw new AssertionError({
646
+ fail(this, new AssertionError({
641
647
  assertion: 'regex',
642
648
  improperUsage: true,
643
649
  message: '`t.regex()` must be called with a string',
644
650
  values: [formatWithLabel('Called with:', string)]
645
- });
651
+ }));
652
+ return;
646
653
  }
647
654
 
648
655
  if (!(regex instanceof RegExp)) {
649
- throw new AssertionError({
656
+ fail(this, new AssertionError({
650
657
  assertion: 'regex',
651
658
  improperUsage: true,
652
659
  message: '`t.regex()` must be called with a regular expression',
653
660
  values: [formatWithLabel('Called with:', regex)]
654
- });
661
+ }));
662
+ return;
655
663
  }
656
664
 
657
665
  if (!regex.test(string)) {
658
- throw new AssertionError({
666
+ fail(this, new AssertionError({
659
667
  assertion: 'regex',
660
668
  message,
661
669
  values: [
662
670
  formatWithLabel('Value must match expression:', string),
663
671
  formatWithLabel('Regular expression:', regex)
664
672
  ]
665
- });
673
+ }));
674
+ return;
666
675
  }
676
+
677
+ pass(this);
667
678
  },
668
679
 
669
680
  notRegex(string, regex, message) {
670
681
  if (typeof string !== 'string') {
671
- throw new AssertionError({
682
+ fail(this, new AssertionError({
672
683
  assertion: 'notRegex',
673
684
  improperUsage: true,
674
685
  message: '`t.notRegex()` must be called with a string',
675
686
  values: [formatWithLabel('Called with:', string)]
676
- });
687
+ }));
688
+ return;
677
689
  }
678
690
 
679
691
  if (!(regex instanceof RegExp)) {
680
- throw new AssertionError({
692
+ fail(this, new AssertionError({
681
693
  assertion: 'notRegex',
682
694
  improperUsage: true,
683
695
  message: '`t.notRegex()` must be called with a regular expression',
684
696
  values: [formatWithLabel('Called with:', regex)]
685
- });
697
+ }));
698
+ return;
686
699
  }
687
700
 
688
701
  if (regex.test(string)) {
689
- throw new AssertionError({
702
+ fail(this, new AssertionError({
690
703
  assertion: 'notRegex',
691
704
  message,
692
705
  values: [
693
706
  formatWithLabel('Value must not match expression:', string),
694
707
  formatWithLabel('Regular expression:', regex)
695
708
  ]
709
+ }));
710
+ return;
711
+ }
712
+
713
+ pass(this);
714
+ }
715
+ };
716
+
717
+ const enhancedAssertions = enhanceAssert(pass, fail, {
718
+ assert(actual, message) {
719
+ if (!actual) {
720
+ throw new AssertionError({
721
+ assertion: 'assert',
722
+ message,
723
+ operator: '!!',
724
+ values: [formatWithLabel('Value is not truthy:', actual)]
696
725
  });
697
726
  }
698
727
  }
package/lib/ava-files.js CHANGED
@@ -171,7 +171,7 @@ class AvaFiles {
171
171
 
172
172
  // Same defaults as used for Chokidar
173
173
  if (!hasPositivePattern) {
174
- mixedPatterns = ['package.json', '**/*.js'].concat(mixedPatterns);
174
+ mixedPatterns = ['package.json', '**/*.js', '**/*.snap'].concat(mixedPatterns);
175
175
  }
176
176
 
177
177
  filePath = matchable(filePath);
@@ -8,12 +8,7 @@ const concordanceOptions = require('./concordance-options').default;
8
8
  // https://github.com/avajs/babel-preset-transform-test-files/blob/master/espower-patterns.json
9
9
  // Then release a new version of that preset and bump the SemVer range here.
10
10
  const PATTERNS = [
11
- 't.truthy(value, [message])',
12
- 't.falsy(value, [message])',
13
- 't.true(value, [message])',
14
- 't.false(value, [message])',
15
- 't.regex(contents, regex, [message])',
16
- 't.notRegex(contents, regex, [message])'
11
+ 't.assert(value, [message])'
17
12
  ];
18
13
 
19
14
  const computeStatement = node => generate(node).code;
@@ -15,7 +15,15 @@ function loadConfig(defaults = {}) {
15
15
  let fileConf;
16
16
  try {
17
17
  ({default: fileConf = MISSING_DEFAULT_EXPORT} = esm(module, {
18
- cjs: false,
18
+ cjs: {
19
+ cache: false,
20
+ extensions: false,
21
+ interop: false,
22
+ mutableNamespace: false,
23
+ namedExports: false,
24
+ paths: false,
25
+ vars: true
26
+ },
19
27
  force: true,
20
28
  mode: 'all'
21
29
  })(path.join(projectDir, 'ava.config.js')));
package/lib/run-status.js CHANGED
@@ -59,7 +59,6 @@ class RunStatus extends Emittery {
59
59
  case 'declared-test':
60
60
  stats.declaredTests++;
61
61
  fileStats.declaredTests++;
62
- this.addPendingTest(event);
63
62
  break;
64
63
  case 'hook-failed':
65
64
  stats.failedHooks++;
@@ -84,6 +83,7 @@ class RunStatus extends Emittery {
84
83
  } else {
85
84
  stats.remainingTests++;
86
85
  fileStats.remainingTests++;
86
+ this.addPendingTest(event);
87
87
  }
88
88
 
89
89
  break;
package/lib/test.js CHANGED
@@ -278,7 +278,7 @@ class Test {
278
278
  }
279
279
 
280
280
  clearTimeout() {
281
- clearTimeout(this.timeoutTimer);
281
+ nowAndTimers.clearTimeout(this.timeoutTimer);
282
282
  this.timeoutTimer = null;
283
283
  }
284
284
 
package/lib/watcher.js CHANGED
@@ -6,6 +6,7 @@ const chokidar = require('chokidar');
6
6
  const flatten = require('arr-flatten');
7
7
  const union = require('array-union');
8
8
  const uniq = require('array-uniq');
9
+ const chalk = require('./chalk').get();
9
10
  const AvaFiles = require('./ava-files');
10
11
 
11
12
  function rethrowAsync(err) {
@@ -18,6 +19,7 @@ function rethrowAsync(err) {
18
19
 
19
20
  const MIN_DEBOUNCE_DELAY = 10;
20
21
  const INITIAL_DEBOUNCE_DELAY = 100;
22
+ const END_MESSAGE = chalk.gray('Type `r` and press enter to rerun tests\nType `u` and press enter to update snapshots\n');
21
23
 
22
24
  class Debouncer {
23
25
  constructor(watcher) {
@@ -123,6 +125,7 @@ class Watcher {
123
125
  })
124
126
  .then(runStatus => {
125
127
  reporter.endRun();
128
+ reporter.lineWriter.writeLine(END_MESSAGE);
126
129
 
127
130
  if (this.clearLogOnNextRun && (
128
131
  runStatus.stats.failedHooks > 0 ||
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  const tty = require('tty');
3
+ const ansiEscapes = require('ansi-escapes');
3
4
  const options = require('./options').get();
4
5
 
5
6
  const fakeTTYs = new Set();
@@ -10,6 +11,27 @@ tty.isatty = fd => fakeTTYs.has(fd) || isatty(fd);
10
11
  const simulateTTY = (stream, {colorDepth, columns, rows}) => {
11
12
  Object.assign(stream, {isTTY: true, columns, rows});
12
13
 
14
+ stream.clearLine = dir => {
15
+ switch (dir) {
16
+ case -1:
17
+ stream.write(ansiEscapes.eraseStartLine);
18
+ break;
19
+ case 1:
20
+ stream.write(ansiEscapes.eraseEndLine);
21
+ break;
22
+ default:
23
+ stream.write(ansiEscapes.eraseLine);
24
+ }
25
+ };
26
+
27
+ stream.clearScreenDown = () => stream.write(ansiEscapes.eraseDown);
28
+
29
+ stream.cursorTo = (x, y) => stream.write(ansiEscapes.cursorTo(x, y));
30
+
31
+ stream.getWindowSize = () => [80, 24];
32
+
33
+ stream.moveCursor = (x, y) => stream.write(ansiEscapes.cursorMove(x, y));
34
+
13
35
  if (colorDepth !== undefined) {
14
36
  stream.getColorDepth = () => colorDepth;
15
37
  }
@@ -111,7 +111,8 @@ ipc.options.then(options => {
111
111
  const required = require(mod);
112
112
 
113
113
  try {
114
- if (required[Symbol.for('esm\u200D:package')]) {
114
+ if (required[Symbol.for('esm:package')] ||
115
+ required[Symbol.for('esm\u200D:package')]) {
115
116
  require = required(module); // eslint-disable-line no-global-assign
116
117
  }
117
118
  } catch (_) {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ava",
3
- "version": "1.2.1",
3
+ "version": "1.4.1",
4
4
  "description": "Testing can be a drag. AVA helps you get it done.",
5
5
  "license": "MIT",
6
6
  "repository": "avajs/ava",
@@ -12,7 +12,7 @@
12
12
  "scripts": {
13
13
  "lint": "xo",
14
14
  "test:flow": "flow check test/flow-types",
15
- "test:tap": "tap --no-cov --reporter=classic --timeout=300 --jobs=2 test/*.js test/reporters/*.js test/integration/*.js",
15
+ "test:tap": "tap --no-esm --no-cov --reporter=classic --timeout=300 --jobs=2 test/*.js test/reporters/*.js test/integration/*.js",
16
16
  "test:typescript": "tsc --noEmit -p test/ts-types",
17
17
  "test": "npm run lint && npm run test:flow && npm run test:typescript && nyc npm run test:tap"
18
18
  },
@@ -61,15 +61,15 @@
61
61
  ],
62
62
  "dependencies": {
63
63
  "@ava/babel-preset-stage-4": "^2.0.0",
64
- "@ava/babel-preset-transform-test-files": "^4.0.1",
64
+ "@ava/babel-preset-transform-test-files": "^5.0.0",
65
65
  "@ava/write-file-atomic": "^2.2.0",
66
- "@babel/core": "^7.2.2",
67
- "@babel/generator": "^7.3.0",
66
+ "@babel/core": "^7.4.0",
67
+ "@babel/generator": "^7.4.0",
68
68
  "@babel/plugin-syntax-async-generators": "^7.2.0",
69
69
  "@babel/plugin-syntax-object-rest-spread": "^7.2.0",
70
70
  "@babel/plugin-syntax-optional-catch-binding": "^7.2.0",
71
71
  "@concordance/react": "^2.0.0",
72
- "ansi-escapes": "^3.1.0",
72
+ "ansi-escapes": "^3.2.0",
73
73
  "ansi-styles": "^3.2.1",
74
74
  "arr-flatten": "^1.1.0",
75
75
  "array-union": "^1.0.1",
@@ -77,7 +77,7 @@
77
77
  "arrify": "^1.0.0",
78
78
  "bluebird": "^3.5.3",
79
79
  "chalk": "^2.4.2",
80
- "chokidar": "^2.0.4",
80
+ "chokidar": "^2.1.5",
81
81
  "chunkd": "^1.0.0",
82
82
  "ci-parallel-vars": "^1.0.0",
83
83
  "clean-stack": "^2.0.0",
@@ -90,16 +90,16 @@
90
90
  "convert-source-map": "^1.6.0",
91
91
  "currently-unhandled": "^0.4.1",
92
92
  "debug": "^4.1.1",
93
- "del": "^3.0.0",
93
+ "del": "^4.0.0",
94
94
  "dot-prop": "^4.2.0",
95
95
  "emittery": "^0.4.1",
96
96
  "empower-core": "^1.2.0",
97
97
  "equal-length": "^1.0.0",
98
98
  "escape-string-regexp": "^1.0.5",
99
- "esm": "^3.1.3",
99
+ "esm": "^3.2.20",
100
100
  "figures": "^2.0.0",
101
101
  "find-up": "^3.0.0",
102
- "get-port": "^4.1.0",
102
+ "get-port": "^4.2.0",
103
103
  "globby": "^7.1.1",
104
104
  "ignore-by-default": "^1.0.0",
105
105
  "import-local": "^2.0.0",
@@ -116,24 +116,24 @@
116
116
  "lodash.difference": "^4.3.0",
117
117
  "lodash.flatten": "^4.2.0",
118
118
  "loud-rejection": "^1.2.0",
119
- "make-dir": "^1.3.0",
119
+ "make-dir": "^2.1.0",
120
120
  "matcher": "^1.1.1",
121
121
  "md5-hex": "^2.0.0",
122
122
  "meow": "^5.0.0",
123
123
  "ms": "^2.1.1",
124
124
  "multimatch": "^3.0.0",
125
125
  "observable-to-promise": "^0.5.0",
126
- "ora": "^3.0.0",
126
+ "ora": "^3.2.0",
127
127
  "package-hash": "^3.0.0",
128
- "pkg-conf": "^2.1.0",
128
+ "pkg-conf": "^3.0.0",
129
129
  "plur": "^3.0.1",
130
130
  "pretty-ms": "^4.0.0",
131
131
  "require-precompiled": "^0.1.0",
132
132
  "resolve-cwd": "^2.0.0",
133
133
  "slash": "^2.0.0",
134
- "source-map-support": "^0.5.10",
134
+ "source-map-support": "^0.5.11",
135
135
  "stack-utils": "^1.0.2",
136
- "strip-ansi": "^5.0.0",
136
+ "strip-ansi": "^5.2.0",
137
137
  "strip-bom-buf": "^1.0.0",
138
138
  "supertap": "^1.0.0",
139
139
  "supports-color": "^6.1.0",
@@ -144,37 +144,37 @@
144
144
  },
145
145
  "devDependencies": {
146
146
  "cli-table3": "^0.5.1",
147
- "codecov": "^3.1.0",
147
+ "codecov": "^3.2.0",
148
148
  "delay": "^4.1.0",
149
149
  "execa": "^1.0.0",
150
- "flow-bin": "^0.91.0",
150
+ "flow-bin": "^0.95.1",
151
151
  "get-stream": "^4.1.0",
152
152
  "git-branch": "^2.0.1",
153
153
  "has-ansi": "^3.0.0",
154
- "lolex": "^3.0.0",
155
- "nyc": "^13.1.0",
154
+ "lolex": "^3.1.0",
155
+ "nyc": "^13.3.0",
156
156
  "proxyquire": "^2.1.0",
157
- "react": "^16.7.0",
158
- "react-test-renderer": "^16.7.0",
157
+ "react": "^16.8.5",
158
+ "react-test-renderer": "^16.8.5",
159
159
  "replace-string": "^2.0.0",
160
160
  "signal-exit": "^3.0.0",
161
- "sinon": "^7.2.3",
161
+ "sinon": "^7.3.0",
162
162
  "source-map-fixtures": "^2.1.0",
163
- "tap": "^12.4.0",
163
+ "tap": "^12.6.1",
164
164
  "temp-write": "^3.4.0",
165
165
  "touch": "^3.1.0",
166
- "ts-node": "^8.0.2",
167
- "typescript": "^3.2.4",
166
+ "ts-node": "^8.0.3",
167
+ "typescript": "^3.3.4000",
168
168
  "xo": "^0.24.0",
169
169
  "zen-observable": "^0.8.13"
170
170
  },
171
- "typings": "index.d.ts",
172
171
  "xo": {
173
172
  "ignores": [
174
173
  "media/**",
175
174
  "test/fixture/ava-paths/target/test.js",
176
175
  "test/fixture/{source-map-initial,syntax-error}.js",
177
176
  "test/fixture/snapshots/test-sourcemaps/build/**",
177
+ "test/fixture/power-assert.js",
178
178
  "**/*.ts",
179
179
  "test/flow-types/*"
180
180
  ],
package/readme.md CHANGED
@@ -184,7 +184,7 @@ In contrast AVA is highly opinionated and runs tests concurrently, with a separa
184
184
 
185
185
  ### How is the name written and pronounced?
186
186
 
187
- AVA, not Ava or ava. Pronounced [eɪvə/ ay-və](media/pronunciation.m4a?raw=true).
187
+ AVA, not Ava or ava. Pronounced [`/ˈeɪvə/`](media/pronunciation.m4a?raw=true): Ay (f**a**ce, m**a**de) V (**v**ie, ha**v**e) A (comm**a**, **a**go)
188
188
 
189
189
  ### What is the header background?
190
190