ava 0.16.0 → 0.18.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/api.js +297 -265
- package/cli.js +15 -179
- package/index.js +5 -98
- package/index.js.flow +201 -0
- package/lib/assert.js +87 -53
- package/lib/ava-error.js +4 -8
- package/lib/ava-files.js +282 -0
- package/lib/babel-config.js +35 -73
- package/lib/beautify-stack.js +17 -16
- package/lib/caching-precompiler.js +72 -87
- package/lib/cli.js +181 -0
- package/lib/code-excerpt.js +57 -0
- package/lib/colors.js +6 -2
- package/lib/concurrent.js +62 -75
- package/lib/enhance-assert.js +57 -49
- package/lib/extract-stack.js +10 -0
- package/lib/fork.js +67 -68
- package/lib/format-assert-error.js +72 -0
- package/lib/globals.js +3 -8
- package/lib/hook.js +15 -20
- package/lib/logger.js +59 -82
- package/lib/main.js +90 -0
- package/lib/prefix-title.js +21 -0
- package/lib/process-adapter.js +108 -0
- package/lib/reporters/mini.js +260 -257
- package/lib/reporters/tap.js +80 -85
- package/lib/reporters/verbose.js +142 -115
- package/lib/run-status.js +110 -152
- package/lib/runner.js +125 -137
- package/lib/sequence.js +68 -84
- package/lib/serialize-error.js +68 -4
- package/lib/snapshot-state.js +30 -0
- package/lib/test-collection.js +144 -156
- package/lib/test-worker.js +45 -95
- package/lib/test.js +289 -318
- package/lib/throws-helper.js +9 -9
- package/lib/validate-test.js +48 -0
- package/lib/watcher.js +258 -297
- package/package.json +63 -53
- package/profile.js +68 -55
- package/readme.md +215 -101
- package/types/generated.d.ts +848 -228
- package/types/make.js +54 -23
- package/lib/send.js +0 -16
package/lib/throws-helper.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
const globals = require('./globals');
|
|
6
6
|
|
|
7
|
-
module.exports =
|
|
7
|
+
module.exports = error => {
|
|
8
8
|
if (!error || !error._avaThrowsHelperData) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const data = error._avaThrowsHelperData;
|
|
13
|
+
const codeFrame = require('babel-code-frame');
|
|
14
|
+
let frame = '';
|
|
15
15
|
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
const rawLines = fs.readFileSync(data.filename, 'utf8');
|
|
18
18
|
frame = codeFrame(rawLines, data.line, data.column, {highlightCode: true});
|
|
19
19
|
} catch (err) {
|
|
20
20
|
console.warn(err);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function validate(title, fn, metadata) {
|
|
4
|
+
if (metadata.type !== 'test') {
|
|
5
|
+
if (metadata.exclusive) {
|
|
6
|
+
return '`only` is only for tests and cannot be used with hooks';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (metadata.failing) {
|
|
10
|
+
return '`failing` is only for tests and cannot be used with hooks';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (metadata.todo) {
|
|
14
|
+
return '`todo` is only for documentation of future tests and cannot be used with hooks';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (metadata.todo) {
|
|
19
|
+
if (typeof fn === 'function') {
|
|
20
|
+
return '`todo` tests are not allowed to have an implementation. Use ' +
|
|
21
|
+
'`test.skip()` for tests with an implementation.';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (typeof title !== 'string') {
|
|
25
|
+
return '`todo` tests require a title';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (metadata.skipped || metadata.failing || metadata.exclusive) {
|
|
29
|
+
return '`todo` tests are just for documentation and cannot be used with `skip`, `only`, or `failing`';
|
|
30
|
+
}
|
|
31
|
+
} else if (typeof fn !== 'function') {
|
|
32
|
+
return 'Expected an implementation. Use `test.todo()` for tests without an implementation.';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (metadata.always) {
|
|
36
|
+
if (!(metadata.type === 'after' || metadata.type === 'afterEach')) {
|
|
37
|
+
return '`always` can only be used with `after` and `afterEach`';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (metadata.skipped && metadata.exclusive) {
|
|
42
|
+
return '`only` tests cannot be skipped';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = validate;
|