@putout/plugin-tape 6.5.0 → 7.1.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
|
@@ -432,17 +432,47 @@ test('should call init before show', (t) => {
|
|
|
432
432
|
|
|
433
433
|
## declare
|
|
434
434
|
|
|
435
|
-
###
|
|
435
|
+
### `mockImport`
|
|
436
|
+
|
|
437
|
+
#### ❌ Incorrect code example
|
|
438
|
+
|
|
439
|
+
```js
|
|
440
|
+
import {stub} from 'supertape';
|
|
441
|
+
|
|
442
|
+
mockImport('fs/promises', {
|
|
443
|
+
readFile: stub().resolves(''),
|
|
444
|
+
});
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
##### ✅ Correct code Example
|
|
448
|
+
|
|
449
|
+
```js
|
|
450
|
+
import {stub} from 'supertape';
|
|
451
|
+
import {createMockImport} from 'mock-import';
|
|
452
|
+
|
|
453
|
+
const {
|
|
454
|
+
mockImport,
|
|
455
|
+
stopAll,
|
|
456
|
+
reImport,
|
|
457
|
+
} = createMockImport(import.meta.url);
|
|
458
|
+
|
|
459
|
+
mockImport('fs/promises', {
|
|
460
|
+
readFile: stub().resolves(''),
|
|
461
|
+
});
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### `tape`
|
|
465
|
+
|
|
466
|
+
#### ❌ Incorrect code example
|
|
436
467
|
|
|
437
468
|
```js
|
|
438
469
|
test('xxx', (t) => {
|
|
439
470
|
const a = stub();
|
|
440
|
-
|
|
441
471
|
t.end();
|
|
442
472
|
});
|
|
443
473
|
```
|
|
444
474
|
|
|
445
|
-
|
|
475
|
+
#### ✅ Correct code example
|
|
446
476
|
|
|
447
477
|
```js
|
|
448
478
|
import {
|
|
@@ -452,7 +482,6 @@ import {
|
|
|
452
482
|
|
|
453
483
|
test('xxx', (t) => {
|
|
454
484
|
const a = stub();
|
|
455
|
-
|
|
456
485
|
t.end();
|
|
457
486
|
});
|
|
458
487
|
```
|
|
@@ -523,7 +552,6 @@ test('stop-all: should be called', (t) => {
|
|
|
523
552
|
mockImport('fs/promises', {
|
|
524
553
|
readFile: stub(),
|
|
525
554
|
});
|
|
526
|
-
|
|
527
555
|
t.end();
|
|
528
556
|
});
|
|
529
557
|
```
|
|
@@ -537,7 +565,6 @@ test('stop-all: should be called', (t) => {
|
|
|
537
565
|
});
|
|
538
566
|
|
|
539
567
|
stopAll();
|
|
540
|
-
|
|
541
568
|
t.end();
|
|
542
569
|
});
|
|
543
570
|
```
|
|
@@ -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,
|
|
7
|
-
't.ok(__a.includes(__b), __c)': 't.match(__a,
|
|
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
|
|
|
@@ -5,4 +5,14 @@ module.exports = {
|
|
|
5
5
|
stub: 'import {stub} from "supertape"',
|
|
6
6
|
Test: 'import {Test} from "supertape"',
|
|
7
7
|
Stub: 'import {Stub} from "supertape"',
|
|
8
|
+
|
|
9
|
+
mockImport: `const {mockImport} = createMockImport(import.meta.url)`,
|
|
10
|
+
reImport: `const {reImport} = createMockImport(import.meta.url)`,
|
|
11
|
+
mockRequire: `import mockRequire from 'mock-require'`,
|
|
12
|
+
reRequire: `const {reRequire} = mockRequire`,
|
|
13
|
+
stopAll: {
|
|
14
|
+
esm: `const {stopAll} = createMockImport(import.meta.url)`,
|
|
15
|
+
commonjs: `const {stopAll} = mockRequire`,
|
|
16
|
+
},
|
|
17
|
+
createMockImport: `import {createMockImport} from 'mock-import'`,
|
|
8
18
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-tape",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.1.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",
|
|
@@ -33,18 +33,18 @@
|
|
|
33
33
|
"putout"
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@putout/test": "^
|
|
36
|
+
"@putout/test": "^4.0.0",
|
|
37
37
|
"c8": "^7.5.0",
|
|
38
38
|
"eslint": "^8.0.1",
|
|
39
39
|
"eslint-plugin-node": "^11.0.0",
|
|
40
|
-
"eslint-plugin-putout": "^
|
|
40
|
+
"eslint-plugin-putout": "^12.0.0",
|
|
41
41
|
"lerna": "^4.0.0",
|
|
42
42
|
"madrun": "^8.0.1",
|
|
43
43
|
"montag": "^1.2.1",
|
|
44
44
|
"nodemon": "^2.0.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"putout": ">=
|
|
47
|
+
"putout": ">=22.5"
|
|
48
48
|
},
|
|
49
49
|
"license": "MIT",
|
|
50
50
|
"engines": {
|