@putout/plugin-tape 7.0.0 → 7.4.0
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/add-args/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const {types} = require('putout');
|
|
4
|
+
|
|
5
|
+
const {isFunction} = types;
|
|
6
|
+
|
|
3
7
|
module.exports.report = () => `Call 'reImport()' using await`;
|
|
4
8
|
|
|
5
9
|
module.exports.match = () => ({
|
|
@@ -15,7 +19,11 @@ module.exports.match = () => ({
|
|
|
15
19
|
|
|
16
20
|
module.exports.replace = () => ({
|
|
17
21
|
'reImport(__a)': (vars, path) => {
|
|
18
|
-
|
|
22
|
+
const fnPath = path.findParent(isFunction);
|
|
23
|
+
|
|
24
|
+
if (fnPath)
|
|
25
|
+
fnPath.node.async = true;
|
|
26
|
+
|
|
19
27
|
return 'await reImport(__a)';
|
|
20
28
|
},
|
|
21
29
|
});
|
package/lib/add-t-end/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
template,
|
|
6
6
|
operator,
|
|
7
7
|
} = require('putout');
|
|
8
|
-
const {compare} = operator;
|
|
8
|
+
const {compare, traverse} = operator;
|
|
9
9
|
const {ExpressionStatement} = types;
|
|
10
10
|
|
|
11
11
|
module.exports.report = () => `'t.end()' is missing at the end of the test`;
|
|
@@ -20,7 +20,7 @@ module.exports.replace = () => ({
|
|
|
20
20
|
'test(__a, async (t) => __body)': replace,
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
function match({__body}) {
|
|
23
|
+
function match({__body}, path) {
|
|
24
24
|
const {body} = __body;
|
|
25
25
|
const {length} = body;
|
|
26
26
|
|
|
@@ -32,7 +32,14 @@ function match({__body}) {
|
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
let found = false;
|
|
36
|
+
traverse(path, {
|
|
37
|
+
't.end()': () => {
|
|
38
|
+
found = true;
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return !found;
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
function replace({__body}, path) {
|
|
@@ -7,8 +7,9 @@ module.exports = {
|
|
|
7
7
|
Stub: 'import {Stub} from "supertape"',
|
|
8
8
|
|
|
9
9
|
mockImport: `const {mockImport} = createMockImport(import.meta.url)`,
|
|
10
|
-
mockRequire: `const mockRequire = require('mock-require')`,
|
|
11
10
|
reImport: `const {reImport} = createMockImport(import.meta.url)`,
|
|
11
|
+
mockRequire: `import mockRequire from 'mock-require'`,
|
|
12
|
+
reRequire: `const {reRequire} = mockRequire`,
|
|
12
13
|
stopAll: {
|
|
13
14
|
esm: `const {stopAll} = createMockImport(import.meta.url)`,
|
|
14
15
|
commonjs: `const {stopAll} = mockRequire`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-tape",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
5
5
|
"description": "putout plugin helps with tests",
|
|
6
6
|
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-tape",
|