@putout/plugin-tape 6.3.0 → 6.7.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/README.md CHANGED
@@ -437,7 +437,6 @@ test('should call init before show', (t) => {
437
437
  ```js
438
438
  test('xxx', (t) => {
439
439
  const a = stub();
440
-
441
440
  t.end();
442
441
  });
443
442
  ```
@@ -452,7 +451,6 @@ import {
452
451
 
453
452
  test('xxx', (t) => {
454
453
  const a = stub();
455
-
456
454
  t.end();
457
455
  });
458
456
  ```
@@ -523,7 +521,6 @@ test('stop-all: should be called', (t) => {
523
521
  mockImport('fs/promises', {
524
522
  readFile: stub(),
525
523
  });
526
-
527
524
  t.end();
528
525
  });
529
526
  ```
@@ -537,7 +534,6 @@ test('stop-all: should be called', (t) => {
537
534
  });
538
535
 
539
536
  stopAll();
540
-
541
537
  t.end();
542
538
  });
543
539
  ```
@@ -6,6 +6,15 @@ const {
6
6
  template,
7
7
  } = require('putout');
8
8
 
9
+ const {
10
+ TEST,
11
+ TEST_ONLY,
12
+ TEST_SKIP,
13
+ TEST_ASYNC,
14
+ TEST_ASYNC_ONLY,
15
+ TEST_ASYNC_SKIP,
16
+ } = require('../test-signatures');
17
+
9
18
  const {
10
19
  traverse,
11
20
  compare,
@@ -22,12 +31,14 @@ module.exports.fix = (path) => {
22
31
  assertionPath.insertBefore(ExpressionStatement(stopAllNode));
23
32
  };
24
33
 
25
- const TEST = 'test("__a", (t) => __body)';
26
- const TEST_ASYNC = 'test("__a", async (t) => __body)';
27
-
28
34
  module.exports.traverse = ({push}) => ({
29
35
  [TEST]: createTraverse(push),
36
+ [TEST_ONLY]: createTraverse(push),
37
+ [TEST_SKIP]: createTraverse(push),
38
+
30
39
  [TEST_ASYNC]: createTraverse(push),
40
+ [TEST_ASYNC_ONLY]: createTraverse(push),
41
+ [TEST_ASYNC_SKIP]: createTraverse(push),
31
42
  });
32
43
 
33
44
  const createTraverse = (push) => (path) => {
@@ -58,6 +69,9 @@ function check(path) {
58
69
  'mockImport(__a, __b)': () => {
59
70
  hasMockImport = true;
60
71
  },
72
+ 'mockRequire(__a, __b)': () => {
73
+ hasMockImport = true;
74
+ },
61
75
  'stopAll()': () => {
62
76
  hasStopAll = true;
63
77
  },
@@ -2,8 +2,12 @@
2
2
 
3
3
  module.exports.report = () => 't.match should be used instead of t.ok with includes';
4
4
 
5
+ module.exports.exclude = () => [
6
+ 't.ok(keys(__a).includes(__b))',
7
+ ];
8
+
5
9
  module.exports.replace = () => ({
6
- 't.ok(__a.includes(__b))': 't.match(__a, RegExp(__b))',
7
- 't.ok(__a.includes(__b), __c)': 't.match(__a, RegExp(__b), __c)',
10
+ 't.ok(__a.includes(__b))': 't.match(__a, __b)',
11
+ 't.ok(__a.includes(__b), __c)': 't.match(__a, __b, __c)',
8
12
  });
9
13
 
@@ -2,6 +2,15 @@
2
2
 
3
3
  const {operator} = require('putout');
4
4
 
5
+ const {
6
+ TEST,
7
+ TEST_ONLY,
8
+ TEST_SKIP,
9
+ TEST_ASYNC,
10
+ TEST_ASYNC_ONLY,
11
+ TEST_ASYNC_SKIP,
12
+ } = require('../test-signatures');
13
+
5
14
  const {traverse} = operator;
6
15
 
7
16
  module.exports.report = () => `Remove 'stopAll()' when you not calling 'reImport()'`;
@@ -10,12 +19,14 @@ module.exports.fix = (path) => {
10
19
  path.remove();
11
20
  };
12
21
 
13
- const TEST = 'test("__a", (t) => __body)';
14
- const TEST_ASYNC = 'test("__a", async (t) => __body)';
15
-
16
22
  module.exports.traverse = ({push}) => ({
17
23
  [TEST]: createTraverse(push),
24
+ [TEST_ONLY]: createTraverse(push),
25
+ [TEST_SKIP]: createTraverse(push),
26
+
18
27
  [TEST_ASYNC]: createTraverse(push),
28
+ [TEST_ASYNC_ONLY]: createTraverse(push),
29
+ [TEST_ASYNC_SKIP]: createTraverse(push),
19
30
  });
20
31
 
21
32
  const createTraverse = (push) => (path) => {
@@ -52,6 +63,9 @@ function check(path) {
52
63
  'mockImport(__a, __b)': () => {
53
64
  hasMockImport = true;
54
65
  },
66
+ 'traceImport(__a, __b)': () => {
67
+ hasReImport = true;
68
+ },
55
69
  'reRequire(__a)': () => {
56
70
  hasReImport = true;
57
71
  },
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ module.exports.TEST = 'test("__a", (t) => __body)';
4
+ module.exports.TEST_ASYNC = 'test("__a", async (t) => __body)';
5
+ module.exports.TEST_ONLY = 'test.only("__a", (t) => __body)';
6
+ module.exports.TEST_ASYNC_ONLY = 'test.only("__a", async (t) => __body)';
7
+ module.exports.TEST_SKIP = 'test.skip("__a", (t) => __body)';
8
+ module.exports.TEST_ASYNC_SKIP = 'test.skip("__a", async (t) => __body)';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-tape",
3
- "version": "6.3.0",
3
+ "version": "6.7.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",