@putout/plugin-tape 8.0.0 → 9.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 +62 -92
- package/lib/convert-does-not-throw-to-try-catch/index.js +0 -4
- package/lib/convert-throws-to-try-catch/index.js +0 -3
- package/lib/index.js +0 -1
- package/lib/remove-only/index.js +7 -4
- package/lib/remove-skip/index.js +8 -4
- package/package.json +6 -6
- package/lib/expand-try-catch-arguments/index.js +0 -43
- package/lib/insert-require-try-catch.js +0 -15
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-tape.svg?style=flat&longCache=true
|
|
4
4
|
[NPMURL]: https://npmjs.org/package/@putout/plugin-tape"npm"
|
|
5
5
|
|
|
6
|
-
[
|
|
6
|
+
🐊[**Putout**](https://github.com/coderaiser/putout) plugin helps to apply best parctises for tests written with 📼[`Supertape`](https://github.com/coderaiser/supertape).
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -33,7 +33,6 @@ npm i @putout/plugin-tape -D
|
|
|
33
33
|
"tape/convert-equal-to-called-once": "on",
|
|
34
34
|
"tape/convert-equal-to-deep-equal": "on",
|
|
35
35
|
"tape/convert-deep-equal-to-equal": "on",
|
|
36
|
-
"tape/expand-try-catch-arguments": "on",
|
|
37
36
|
"tape/convert-emitter-to-promise": "on",
|
|
38
37
|
"tape/convert-ok-to-match": "on",
|
|
39
38
|
"tape/convert-ok-to-called-with": "on",
|
|
@@ -51,7 +50,7 @@ npm i @putout/plugin-tape -D
|
|
|
51
50
|
|
|
52
51
|
## switch-expected-with-result
|
|
53
52
|
|
|
54
|
-
### ❌
|
|
53
|
+
### ❌ Example of incorrect code
|
|
55
54
|
|
|
56
55
|
```js
|
|
57
56
|
test('plugin-apply-destructuring: transform: array: destructuring', (t) => {
|
|
@@ -60,7 +59,7 @@ test('plugin-apply-destructuring: transform: array: destructuring', (t) => {
|
|
|
60
59
|
});
|
|
61
60
|
```
|
|
62
61
|
|
|
63
|
-
### ✅
|
|
62
|
+
### ✅ Example of correct code
|
|
64
63
|
|
|
65
64
|
```js
|
|
66
65
|
test('plugin-apply-destructuring: transform: array: destructuring', (t) => {
|
|
@@ -71,13 +70,13 @@ test('plugin-apply-destructuring: transform: array: destructuring', (t) => {
|
|
|
71
70
|
|
|
72
71
|
## convert-tape-to-supertape
|
|
73
72
|
|
|
74
|
-
### ❌
|
|
73
|
+
### ❌ Example of incorrect code
|
|
75
74
|
|
|
76
75
|
```js
|
|
77
76
|
const test = require('tape');
|
|
78
77
|
```
|
|
79
78
|
|
|
80
|
-
### ✅
|
|
79
|
+
### ✅ Example of correct code
|
|
81
80
|
|
|
82
81
|
```js
|
|
83
82
|
const test = require('supertape');
|
|
@@ -85,7 +84,7 @@ const test = require('supertape');
|
|
|
85
84
|
|
|
86
85
|
## convert-throws-to-try-catch
|
|
87
86
|
|
|
88
|
-
### ❌
|
|
87
|
+
### ❌ Example of incorrect code
|
|
89
88
|
|
|
90
89
|
```js
|
|
91
90
|
const test = require('supertape');
|
|
@@ -96,7 +95,7 @@ test('some message', (t) => {
|
|
|
96
95
|
});
|
|
97
96
|
```
|
|
98
97
|
|
|
99
|
-
### ✅
|
|
98
|
+
### ✅ Example of correct code
|
|
100
99
|
|
|
101
100
|
```js
|
|
102
101
|
const tryCatch = require('try-catch');
|
|
@@ -112,7 +111,7 @@ test('some message', (t) => {
|
|
|
112
111
|
|
|
113
112
|
## convert-does-not-throw-to-try-catch
|
|
114
113
|
|
|
115
|
-
### ❌
|
|
114
|
+
### ❌ Example of incorrect code
|
|
116
115
|
|
|
117
116
|
```js
|
|
118
117
|
const test = require('supertape');
|
|
@@ -123,7 +122,7 @@ test('some message', (t) => {
|
|
|
123
122
|
});
|
|
124
123
|
```
|
|
125
124
|
|
|
126
|
-
### ✅
|
|
125
|
+
### ✅ Example of correct code
|
|
127
126
|
|
|
128
127
|
```js
|
|
129
128
|
const test = require('supertape');
|
|
@@ -139,7 +138,7 @@ test('some test', (t) => {
|
|
|
139
138
|
|
|
140
139
|
## convert-called-with-args
|
|
141
140
|
|
|
142
|
-
### ❌
|
|
141
|
+
### ❌ Example of incorrect code
|
|
143
142
|
|
|
144
143
|
```js
|
|
145
144
|
const test = require('supertape');
|
|
@@ -155,7 +154,7 @@ test('some message', (t) => {
|
|
|
155
154
|
});
|
|
156
155
|
```
|
|
157
156
|
|
|
158
|
-
### ✅
|
|
157
|
+
### ✅ Example of correct code
|
|
159
158
|
|
|
160
159
|
```js
|
|
161
160
|
const test = require('supertape');
|
|
@@ -175,7 +174,7 @@ test('some message', (t) => {
|
|
|
175
174
|
|
|
176
175
|
No need to use [`equal`](https://github.com/coderaiser/supertape#tequalactual-expected-msg), [`supertape`](https://github.com/coderaiser/supertape) supports [`calledOnce`](https://github.com/coderaiser/supertape/tree/master/packages/operator-stub#tcalledoncefn--message).
|
|
177
176
|
|
|
178
|
-
### ❌
|
|
177
|
+
### ❌ Example of incorrect code
|
|
179
178
|
|
|
180
179
|
```js
|
|
181
180
|
const test = require('supertape');
|
|
@@ -191,7 +190,7 @@ test('some message', (t) => {
|
|
|
191
190
|
});
|
|
192
191
|
```
|
|
193
192
|
|
|
194
|
-
### ✅
|
|
193
|
+
### ✅ Example of correct code
|
|
195
194
|
|
|
196
195
|
```js
|
|
197
196
|
const test = require('supertape');
|
|
@@ -211,7 +210,7 @@ test('some message', (t) => {
|
|
|
211
210
|
|
|
212
211
|
Use [`equal`](https://github.com/coderaiser/supertape#tequalactual-expected-msg) when comparing with primitives, [`deepEqual`](https://github.com/coderaiser/supertape#tdeepequalactual-expected-msg) for [`Objects`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) and [`Arrays`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array);
|
|
213
212
|
|
|
214
|
-
### ❌
|
|
213
|
+
### ❌ Example of incorrect code
|
|
215
214
|
|
|
216
215
|
```js
|
|
217
216
|
const test = require('supertape');
|
|
@@ -223,7 +222,7 @@ test('some message', (t) => {
|
|
|
223
222
|
});
|
|
224
223
|
```
|
|
225
224
|
|
|
226
|
-
### ✅
|
|
225
|
+
### ✅ Example of correct code
|
|
227
226
|
|
|
228
227
|
```js
|
|
229
228
|
const test = require('supertape');
|
|
@@ -237,7 +236,7 @@ test('some message', (t) => {
|
|
|
237
236
|
|
|
238
237
|
## convert-called-with-to-called-with-no-args
|
|
239
238
|
|
|
240
|
-
### ❌
|
|
239
|
+
### ❌ Example of incorrect code
|
|
241
240
|
|
|
242
241
|
```js
|
|
243
242
|
const test = require('supertape');
|
|
@@ -253,7 +252,7 @@ test('some message', (t) => {
|
|
|
253
252
|
});
|
|
254
253
|
```
|
|
255
254
|
|
|
256
|
-
### ✅
|
|
255
|
+
### ✅ Example of correct code
|
|
257
256
|
|
|
258
257
|
```js
|
|
259
258
|
const test = require('supertape');
|
|
@@ -271,7 +270,7 @@ test('some message', (t) => {
|
|
|
271
270
|
|
|
272
271
|
## convert-called-with-no-args-to-called-with
|
|
273
272
|
|
|
274
|
-
### ❌
|
|
273
|
+
### ❌ Example of incorrect code
|
|
275
274
|
|
|
276
275
|
```js
|
|
277
276
|
const test = require('supertape');
|
|
@@ -287,7 +286,7 @@ test('some message', (t) => {
|
|
|
287
286
|
});
|
|
288
287
|
```
|
|
289
288
|
|
|
290
|
-
### ✅
|
|
289
|
+
### ✅ Example of correct code
|
|
291
290
|
|
|
292
291
|
```js
|
|
293
292
|
const test = require('supertape');
|
|
@@ -305,7 +304,7 @@ test('some message', (t) => {
|
|
|
305
304
|
|
|
306
305
|
## convert-emitter-to-promise
|
|
307
306
|
|
|
308
|
-
### ❌
|
|
307
|
+
### ❌ Example of incorrect code
|
|
309
308
|
|
|
310
309
|
```js
|
|
311
310
|
test('copymitter', (t) => {
|
|
@@ -317,7 +316,7 @@ test('copymitter', (t) => {
|
|
|
317
316
|
});
|
|
318
317
|
```
|
|
319
318
|
|
|
320
|
-
### ✅
|
|
319
|
+
### ✅ Example of correct code
|
|
321
320
|
|
|
322
321
|
```js
|
|
323
322
|
const {once} = require('events');
|
|
@@ -330,38 +329,9 @@ test('copymitter', async (t) => {
|
|
|
330
329
|
});
|
|
331
330
|
```
|
|
332
331
|
|
|
333
|
-
## expand-try-catch-arguments
|
|
334
|
-
|
|
335
|
-
### ❌ Incorrect code example
|
|
336
|
-
|
|
337
|
-
```js
|
|
338
|
-
import tryCatch from 'try-catch';
|
|
339
|
-
|
|
340
|
-
test('some message', (t) => {
|
|
341
|
-
const fn = () => copymitter('/hello');
|
|
342
|
-
const [error] = tryCatch(fn);
|
|
343
|
-
|
|
344
|
-
t.equal(error.message, 'to should be a string!');
|
|
345
|
-
t.end();
|
|
346
|
-
});
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
### ✅ Correct code example
|
|
350
|
-
|
|
351
|
-
```js
|
|
352
|
-
import tryCatch from 'try-catch';
|
|
353
|
-
|
|
354
|
-
test('some message', (t) => {
|
|
355
|
-
const [error] = tryCatch(copymitter, '/hello');
|
|
356
|
-
|
|
357
|
-
t.equal(error.message, 'to should be a string!');
|
|
358
|
-
t.end();
|
|
359
|
-
});
|
|
360
|
-
```
|
|
361
|
-
|
|
362
332
|
## apply-stub-operator
|
|
363
333
|
|
|
364
|
-
### ❌
|
|
334
|
+
### ❌ Example of incorrect code
|
|
365
335
|
|
|
366
336
|
```js
|
|
367
337
|
test('some message', (t) => {
|
|
@@ -370,7 +340,7 @@ test('some message', (t) => {
|
|
|
370
340
|
});
|
|
371
341
|
```
|
|
372
342
|
|
|
373
|
-
### ✅
|
|
343
|
+
### ✅ Example of correct code
|
|
374
344
|
|
|
375
345
|
```js
|
|
376
346
|
test('some message', (t) => {
|
|
@@ -381,7 +351,7 @@ test('some message', (t) => {
|
|
|
381
351
|
|
|
382
352
|
## apply-with-name
|
|
383
353
|
|
|
384
|
-
### ❌
|
|
354
|
+
### ❌ Example of incorrect code
|
|
385
355
|
|
|
386
356
|
```js
|
|
387
357
|
test('should call init before show', (t) => {
|
|
@@ -393,7 +363,7 @@ test('should call init before show', (t) => {
|
|
|
393
363
|
});
|
|
394
364
|
```
|
|
395
365
|
|
|
396
|
-
### ✅
|
|
366
|
+
### ✅ Example of correct code
|
|
397
367
|
|
|
398
368
|
```js
|
|
399
369
|
test('should call init before show', (t) => {
|
|
@@ -407,7 +377,7 @@ test('should call init before show', (t) => {
|
|
|
407
377
|
|
|
408
378
|
## sync-with-name
|
|
409
379
|
|
|
410
|
-
### ❌
|
|
380
|
+
### ❌ Example of incorrect code
|
|
411
381
|
|
|
412
382
|
```js
|
|
413
383
|
test('should call init before show', (t) => {
|
|
@@ -419,7 +389,7 @@ test('should call init before show', (t) => {
|
|
|
419
389
|
});
|
|
420
390
|
```
|
|
421
391
|
|
|
422
|
-
### ✅
|
|
392
|
+
### ✅ Example of correct code
|
|
423
393
|
|
|
424
394
|
```js
|
|
425
395
|
test('should call init before show', (t) => {
|
|
@@ -435,7 +405,7 @@ test('should call init before show', (t) => {
|
|
|
435
405
|
|
|
436
406
|
### `mockImport`
|
|
437
407
|
|
|
438
|
-
#### ❌
|
|
408
|
+
#### ❌ Example of incorrect code
|
|
439
409
|
|
|
440
410
|
```js
|
|
441
411
|
import {stub} from 'supertape';
|
|
@@ -445,7 +415,7 @@ mockImport('fs/promises', {
|
|
|
445
415
|
});
|
|
446
416
|
```
|
|
447
417
|
|
|
448
|
-
##### ✅
|
|
418
|
+
##### ✅ Example of correct code
|
|
449
419
|
|
|
450
420
|
```js
|
|
451
421
|
import {stub} from 'supertape';
|
|
@@ -464,7 +434,7 @@ mockImport('fs/promises', {
|
|
|
464
434
|
|
|
465
435
|
### `tape`
|
|
466
436
|
|
|
467
|
-
#### ❌
|
|
437
|
+
#### ❌ Example of incorrect code
|
|
468
438
|
|
|
469
439
|
```js
|
|
470
440
|
test('xxx', (t) => {
|
|
@@ -473,7 +443,7 @@ test('xxx', (t) => {
|
|
|
473
443
|
});
|
|
474
444
|
```
|
|
475
445
|
|
|
476
|
-
#### ✅
|
|
446
|
+
#### ✅ Example of correct code
|
|
477
447
|
|
|
478
448
|
```js
|
|
479
449
|
import {
|
|
@@ -489,7 +459,7 @@ test('xxx', (t) => {
|
|
|
489
459
|
|
|
490
460
|
## add-args
|
|
491
461
|
|
|
492
|
-
### ❌
|
|
462
|
+
### ❌ Example of incorrect code
|
|
493
463
|
|
|
494
464
|
```js
|
|
495
465
|
test('xxx', () => {
|
|
@@ -497,7 +467,7 @@ test('xxx', () => {
|
|
|
497
467
|
});
|
|
498
468
|
```
|
|
499
469
|
|
|
500
|
-
### ✅
|
|
470
|
+
### ✅ Example of correct code
|
|
501
471
|
|
|
502
472
|
```js
|
|
503
473
|
test('xxx', (t) => {
|
|
@@ -507,14 +477,14 @@ test('xxx', (t) => {
|
|
|
507
477
|
|
|
508
478
|
## add-t-end
|
|
509
479
|
|
|
510
|
-
### ❌
|
|
480
|
+
### ❌ Example of incorrect code
|
|
511
481
|
|
|
512
482
|
```js
|
|
513
483
|
test('xxx', () => {
|
|
514
484
|
});
|
|
515
485
|
```
|
|
516
486
|
|
|
517
|
-
### ✅
|
|
487
|
+
### ✅ Example of correct code
|
|
518
488
|
|
|
519
489
|
```js
|
|
520
490
|
test('xxx', (t) => {
|
|
@@ -524,7 +494,7 @@ test('xxx', (t) => {
|
|
|
524
494
|
|
|
525
495
|
## add-await-to-re-import
|
|
526
496
|
|
|
527
|
-
### ❌
|
|
497
|
+
### ❌ Example of incorrect code
|
|
528
498
|
|
|
529
499
|
```js
|
|
530
500
|
test('stop-all: should be called', (t) => {
|
|
@@ -533,7 +503,7 @@ test('stop-all: should be called', (t) => {
|
|
|
533
503
|
});
|
|
534
504
|
```
|
|
535
505
|
|
|
536
|
-
### ✅
|
|
506
|
+
### ✅ Example of correct code
|
|
537
507
|
|
|
538
508
|
```js
|
|
539
509
|
test('stop-all: should be called', async (t) => {
|
|
@@ -546,7 +516,7 @@ test('stop-all: should be called', async (t) => {
|
|
|
546
516
|
|
|
547
517
|
When you write test mocking `ESM` with [`mockImport()`](https://github.com/coderaiser/mock-import#mockimportname-mock) never forget to call [`stopAll()`](https://github.com/coderaiser/mock-import#stopall) when you no longer need it. This leads to bugs in tests which are hard to find, each test should be checked with the one which pass when called alone but fail when called with others.
|
|
548
518
|
|
|
549
|
-
### ❌
|
|
519
|
+
### ❌ Example of incorrect code
|
|
550
520
|
|
|
551
521
|
```js
|
|
552
522
|
test('stop-all: should be called', (t) => {
|
|
@@ -557,7 +527,7 @@ test('stop-all: should be called', (t) => {
|
|
|
557
527
|
});
|
|
558
528
|
```
|
|
559
529
|
|
|
560
|
-
### ✅
|
|
530
|
+
### ✅ Example of correct code
|
|
561
531
|
|
|
562
532
|
```js
|
|
563
533
|
test('stop-all: should be called', (t) => {
|
|
@@ -572,7 +542,7 @@ test('stop-all: should be called', (t) => {
|
|
|
572
542
|
|
|
573
543
|
## remove-useless-t-end
|
|
574
544
|
|
|
575
|
-
### ❌
|
|
545
|
+
### ❌ Example of incorrect code
|
|
576
546
|
|
|
577
547
|
```js
|
|
578
548
|
test('test: remove me', () => {
|
|
@@ -581,7 +551,7 @@ test('test: remove me', () => {
|
|
|
581
551
|
});
|
|
582
552
|
```
|
|
583
553
|
|
|
584
|
-
### ✅
|
|
554
|
+
### ✅ Example of correct code
|
|
585
555
|
|
|
586
556
|
```js
|
|
587
557
|
test('test: remove me', () => {
|
|
@@ -591,13 +561,13 @@ test('test: remove me', () => {
|
|
|
591
561
|
|
|
592
562
|
## convert-ok-to-match
|
|
593
563
|
|
|
594
|
-
### ❌
|
|
564
|
+
### ❌ Example of incorrect code
|
|
595
565
|
|
|
596
566
|
```js
|
|
597
567
|
t.ok(result.includes('hello'));
|
|
598
568
|
```
|
|
599
569
|
|
|
600
|
-
### ✅
|
|
570
|
+
### ✅ Example of correct code
|
|
601
571
|
|
|
602
572
|
```js
|
|
603
573
|
t.match(result, /hello/);
|
|
@@ -605,13 +575,13 @@ t.match(result, /hello/);
|
|
|
605
575
|
|
|
606
576
|
## convert-ok-to-match
|
|
607
577
|
|
|
608
|
-
### ❌
|
|
578
|
+
### ❌ Example of incorrect code
|
|
609
579
|
|
|
610
580
|
```js
|
|
611
581
|
t.ok(set.calledWith(1, 2));
|
|
612
582
|
```
|
|
613
583
|
|
|
614
|
-
### ✅
|
|
584
|
+
### ✅ Example of correct code
|
|
615
585
|
|
|
616
586
|
```js
|
|
617
587
|
t.calledWith(set, [1, 2]);
|
|
@@ -619,13 +589,13 @@ t.calledWith(set, [1, 2]);
|
|
|
619
589
|
|
|
620
590
|
## convert-equal-to-not-ok
|
|
621
591
|
|
|
622
|
-
### ❌
|
|
592
|
+
### ❌ Example of incorrect code
|
|
623
593
|
|
|
624
594
|
```js
|
|
625
595
|
t.equal(error, null);
|
|
626
596
|
```
|
|
627
597
|
|
|
628
|
-
### ✅
|
|
598
|
+
### ✅ Example of correct code
|
|
629
599
|
|
|
630
600
|
```js
|
|
631
601
|
t.notOk(error);
|
|
@@ -633,13 +603,13 @@ t.notOk(error);
|
|
|
633
603
|
|
|
634
604
|
## convert-equal-to-ok
|
|
635
605
|
|
|
636
|
-
### ❌
|
|
606
|
+
### ❌ Example of incorrect code
|
|
637
607
|
|
|
638
608
|
```js
|
|
639
609
|
t.equal(result, true);
|
|
640
610
|
```
|
|
641
611
|
|
|
642
|
-
### ✅
|
|
612
|
+
### ✅ Example of correct code
|
|
643
613
|
|
|
644
614
|
```js
|
|
645
615
|
t.ok(result);
|
|
@@ -647,7 +617,7 @@ t.ok(result);
|
|
|
647
617
|
|
|
648
618
|
## convert-equal-to-deep-equal
|
|
649
619
|
|
|
650
|
-
### ❌
|
|
620
|
+
### ❌ Example of incorrect code
|
|
651
621
|
|
|
652
622
|
```js
|
|
653
623
|
const expected = {
|
|
@@ -658,7 +628,7 @@ t.equal(error, expected);
|
|
|
658
628
|
t.end();
|
|
659
629
|
```
|
|
660
630
|
|
|
661
|
-
### ✅
|
|
631
|
+
### ✅ Example of correct code
|
|
662
632
|
|
|
663
633
|
```js
|
|
664
634
|
const expected = {
|
|
@@ -671,13 +641,13 @@ t.end();
|
|
|
671
641
|
|
|
672
642
|
## convert-match-regexp-to-string
|
|
673
643
|
|
|
674
|
-
### ❌
|
|
644
|
+
### ❌ Example of incorrect code
|
|
675
645
|
|
|
676
646
|
```js
|
|
677
647
|
t.match(result, RegExp('hello'));
|
|
678
648
|
```
|
|
679
649
|
|
|
680
|
-
### ✅
|
|
650
|
+
### ✅ Example of correct code
|
|
681
651
|
|
|
682
652
|
```js
|
|
683
653
|
t.match(result, 'hello');
|
|
@@ -688,13 +658,13 @@ t.match(result, 'hello');
|
|
|
688
658
|
`supertape` will put this information for you, and it is always the same.
|
|
689
659
|
No need to repeat the same information twice on one line, better to avoid it.
|
|
690
660
|
|
|
691
|
-
### ❌
|
|
661
|
+
### ❌ Example of incorrect code
|
|
692
662
|
|
|
693
663
|
```js
|
|
694
664
|
t.equal(result, expected, 'should equal');
|
|
695
665
|
```
|
|
696
666
|
|
|
697
|
-
### ✅
|
|
667
|
+
### ✅ Example of correct code
|
|
698
668
|
|
|
699
669
|
```js
|
|
700
670
|
t.equal(result, expected);
|
|
@@ -702,13 +672,13 @@ t.equal(result, expected);
|
|
|
702
672
|
|
|
703
673
|
## remove-useless-not-called-args
|
|
704
674
|
|
|
705
|
-
### ❌
|
|
675
|
+
### ❌ Example of incorrect code
|
|
706
676
|
|
|
707
677
|
```js
|
|
708
678
|
t.notCalled(fn, []);
|
|
709
679
|
```
|
|
710
680
|
|
|
711
|
-
### ✅
|
|
681
|
+
### ✅ Example of correct code
|
|
712
682
|
|
|
713
683
|
```js
|
|
714
684
|
t.notCalled(fn);
|
|
@@ -716,7 +686,7 @@ t.notCalled(fn);
|
|
|
716
686
|
|
|
717
687
|
## remove-only
|
|
718
688
|
|
|
719
|
-
### ❌
|
|
689
|
+
### ❌ Example of incorrect code
|
|
720
690
|
|
|
721
691
|
```js
|
|
722
692
|
test.only('some test', (t) => {
|
|
@@ -725,7 +695,7 @@ test.only('some test', (t) => {
|
|
|
725
695
|
|
|
726
696
|
```
|
|
727
697
|
|
|
728
|
-
### ✅
|
|
698
|
+
### ✅ Example of correct code
|
|
729
699
|
|
|
730
700
|
```js
|
|
731
701
|
test('some test', (t) => {
|
|
@@ -735,7 +705,7 @@ test('some test', (t) => {
|
|
|
735
705
|
|
|
736
706
|
## remove-skip
|
|
737
707
|
|
|
738
|
-
### ❌
|
|
708
|
+
### ❌ Example of incorrect code
|
|
739
709
|
|
|
740
710
|
```js
|
|
741
711
|
test.skip('some test', (t) => {
|
|
@@ -748,7 +718,7 @@ test.skip('some test', (t) => {
|
|
|
748
718
|
|
|
749
719
|
When `reImport()` or `reRequire` not called, `stopAll()` is redundant and should be removed.
|
|
750
720
|
|
|
751
|
-
### ❌
|
|
721
|
+
### ❌ Example of incorrect code
|
|
752
722
|
|
|
753
723
|
```js
|
|
754
724
|
test('some test', (t) => {
|
|
@@ -758,7 +728,7 @@ test('some test', (t) => {
|
|
|
758
728
|
|
|
759
729
|
```
|
|
760
730
|
|
|
761
|
-
### ✅
|
|
731
|
+
### ✅ Example of correct code
|
|
762
732
|
|
|
763
733
|
```js
|
|
764
734
|
test('some test', (t) => {
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const {template} = require('putout');
|
|
4
4
|
|
|
5
|
-
const insertRequireTryCatch = require('../insert-require-try-catch');
|
|
6
|
-
|
|
7
5
|
module.exports.report = () => 'try-catch should be used instead of t.doesNotThrow';
|
|
8
6
|
|
|
9
7
|
module.exports.replace = () => ({
|
|
@@ -13,9 +11,7 @@ module.exports.replace = () => ({
|
|
|
13
11
|
`);
|
|
14
12
|
|
|
15
13
|
tryCatchNode.declarations[0].init.arguments[0] = __a;
|
|
16
|
-
|
|
17
14
|
path.insertBefore(tryCatchNode);
|
|
18
|
-
insertRequireTryCatch(path);
|
|
19
15
|
|
|
20
16
|
return `t.notOk(error, __b)`;
|
|
21
17
|
},
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {template} = require('putout');
|
|
4
|
-
const insertRequireTryCatch = require('../insert-require-try-catch');
|
|
5
4
|
|
|
6
5
|
module.exports.report = () => 'try-catch should be used instead of t.throws';
|
|
7
6
|
|
|
@@ -22,8 +21,6 @@ function putTryCatch(__a, path) {
|
|
|
22
21
|
`);
|
|
23
22
|
|
|
24
23
|
tryCatchNode.declarations[0].init.arguments[0] = __a;
|
|
25
|
-
|
|
26
24
|
path.insertBefore(tryCatchNode);
|
|
27
|
-
insertRequireTryCatch(path);
|
|
28
25
|
}
|
|
29
26
|
|
package/lib/index.js
CHANGED
|
@@ -23,7 +23,6 @@ module.exports.rules = {
|
|
|
23
23
|
...getRule('convert-equal-to-ok'),
|
|
24
24
|
...getRule('convert-equal-to-called-once'),
|
|
25
25
|
...getRule('convert-deep-equal-to-equal'),
|
|
26
|
-
...getRule('expand-try-catch-arguments'),
|
|
27
26
|
...getRule('add-args'),
|
|
28
27
|
...getRule('declare'),
|
|
29
28
|
...getRule('remove-default-messages'),
|
package/lib/remove-only/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const {types} = require('putout');
|
|
4
|
+
const {isIdentifier} = types;
|
|
5
|
+
|
|
6
|
+
module.exports.report = () => `Remove 'test.only'`;
|
|
4
7
|
|
|
5
8
|
module.exports.replace = () => ({
|
|
6
9
|
'__a.only(__b, __c)': '__a(__b, __c)',
|
|
7
10
|
'__a.only(__b, __c, __d)': '__a(__b, __c, __d)',
|
|
8
|
-
'__a["only"](__b, __c)': '__a(__b, __c)',
|
|
9
11
|
});
|
|
10
12
|
|
|
11
13
|
module.exports.filter = (path) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
return isIdentifier(path.node.callee.object, {
|
|
15
|
+
name: 'test',
|
|
16
|
+
});
|
|
14
17
|
};
|
|
15
18
|
|
package/lib/remove-skip/index.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const {types} = require('putout');
|
|
4
|
+
|
|
5
|
+
const {isIdentifier} = types;
|
|
6
|
+
|
|
7
|
+
module.exports.report = () => 'Remove "test.skip"';
|
|
4
8
|
|
|
5
9
|
module.exports.replace = () => ({
|
|
6
10
|
'__a.skip(__b, __c)': '__a(__b, __c)',
|
|
7
11
|
'__a.skip(__b, __c, __d)': '__a(__b, __c, __d)',
|
|
8
|
-
'__a["skip"](__b, __c)': '__a(__b, __c)',
|
|
9
12
|
});
|
|
10
13
|
|
|
11
14
|
module.exports.filter = (path) => {
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
return isIdentifier(path.node.callee.object, {
|
|
16
|
+
name: 'test',
|
|
17
|
+
});
|
|
14
18
|
};
|
|
15
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-tape",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "putout plugin helps with tests",
|
|
@@ -31,22 +31,22 @@
|
|
|
31
31
|
"putout"
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@putout/test": "^
|
|
34
|
+
"@putout/test": "^5.0.0",
|
|
35
35
|
"c8": "^7.5.0",
|
|
36
36
|
"eslint": "^8.0.1",
|
|
37
37
|
"eslint-plugin-node": "^11.0.0",
|
|
38
|
-
"eslint-plugin-putout": "^
|
|
38
|
+
"eslint-plugin-putout": "^14.0.0",
|
|
39
39
|
"lerna": "^4.0.0",
|
|
40
|
-
"madrun": "^
|
|
40
|
+
"madrun": "^9.0.0",
|
|
41
41
|
"montag": "^1.2.1",
|
|
42
42
|
"nodemon": "^2.0.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"putout": ">=
|
|
45
|
+
"putout": ">=25"
|
|
46
46
|
},
|
|
47
47
|
"license": "MIT",
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
49
|
+
"node": ">=16"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports.report = () => 'try-catch arguments should be expanded';
|
|
4
|
-
|
|
5
|
-
module.exports.match = () => ({
|
|
6
|
-
'tryCatch(__args)': ({__args}, path) => {
|
|
7
|
-
const [fn] = __args;
|
|
8
|
-
const {name} = fn;
|
|
9
|
-
const {bindings} = path.scope;
|
|
10
|
-
|
|
11
|
-
if (!bindings[name])
|
|
12
|
-
return false;
|
|
13
|
-
|
|
14
|
-
const initPath = bindings[name].path.get('init');
|
|
15
|
-
|
|
16
|
-
if (!initPath.isFunction())
|
|
17
|
-
return false;
|
|
18
|
-
|
|
19
|
-
const bodyPath = initPath.get('body');
|
|
20
|
-
|
|
21
|
-
return bodyPath.isCallExpression();
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
module.exports.replace = () => ({
|
|
26
|
-
'tryCatch(__args)': ({__args}, path) => {
|
|
27
|
-
const [fn] = __args;
|
|
28
|
-
const {name} = fn;
|
|
29
|
-
const {bindings} = path.scope;
|
|
30
|
-
|
|
31
|
-
const fnPath = bindings[name].path;
|
|
32
|
-
const {node} = fnPath.get('init.body');
|
|
33
|
-
const newArgs = [
|
|
34
|
-
node.callee,
|
|
35
|
-
...node.arguments,
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
path.node.arguments = newArgs;
|
|
39
|
-
fnPath.remove();
|
|
40
|
-
|
|
41
|
-
return path;
|
|
42
|
-
},
|
|
43
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const {template} = require('putout');
|
|
4
|
-
|
|
5
|
-
const requireTryCatch = template.ast(`const tryCatch = require('try-catch')`);
|
|
6
|
-
|
|
7
|
-
module.exports = (path) => {
|
|
8
|
-
const parentScope = path.scope.getProgramParent();
|
|
9
|
-
|
|
10
|
-
if (parentScope.bindings.tryCatch)
|
|
11
|
-
return;
|
|
12
|
-
|
|
13
|
-
parentScope.block.body.unshift(requireTryCatch);
|
|
14
|
-
};
|
|
15
|
-
|