@putout/test 8.0.0 → 8.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 +14 -0
- package/lib/test.js +24 -2
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -231,6 +231,20 @@ test('plugin-apply-numeric-separators: no transform: hex', (t) => {
|
|
|
231
231
|
});
|
|
232
232
|
```
|
|
233
233
|
|
|
234
|
+
### `progress(filename, expected)`
|
|
235
|
+
|
|
236
|
+
Check progress of `filename.js`;
|
|
237
|
+
|
|
238
|
+
```js
|
|
239
|
+
test('remove usless variables: for-of', async ({progress}) => {
|
|
240
|
+
await progress('progress', {
|
|
241
|
+
i: 0,
|
|
242
|
+
n: 2,
|
|
243
|
+
rule: 'read-all-files',
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
234
248
|
## Formatters API
|
|
235
249
|
|
|
236
250
|
First you need to create test with:
|
package/lib/test.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const process = require('node:process');
|
|
4
|
-
const {join} = require('path');
|
|
4
|
+
const {join} = require('node:path');
|
|
5
|
+
const {once} = require('node:events');
|
|
5
6
|
|
|
6
7
|
const {
|
|
7
8
|
readFileSync,
|
|
8
9
|
writeFileSync,
|
|
9
10
|
existsSync,
|
|
10
11
|
unlinkSync,
|
|
11
|
-
} = require('fs');
|
|
12
|
+
} = require('node:fs');
|
|
12
13
|
|
|
13
14
|
const tryCatch = require('try-catch');
|
|
14
15
|
const test = require('supertape');
|
|
15
16
|
const putout = require('putout');
|
|
16
17
|
const currify = require('currify');
|
|
18
|
+
const {createProgress} = require('@putout/engine-runner/progress');
|
|
17
19
|
|
|
18
20
|
const {preTest} = require('./pre-test');
|
|
19
21
|
const {isArray} = Array;
|
|
@@ -104,6 +106,8 @@ function createTest(dir, maybeOptions) {
|
|
|
104
106
|
transformCode: transformCode(options),
|
|
105
107
|
noTransformCode: noTransformCode(options),
|
|
106
108
|
|
|
109
|
+
progress: progress(dir, options),
|
|
110
|
+
|
|
107
111
|
transformWithOptions: transformWithOptions(dir, options),
|
|
108
112
|
noTransformWithOptions: noTransformWithOptions(dir, options),
|
|
109
113
|
|
|
@@ -270,6 +274,24 @@ const toObject = (array) => {
|
|
|
270
274
|
return result;
|
|
271
275
|
};
|
|
272
276
|
|
|
277
|
+
const progress = (dir, options) => (t) => async (name, expected) => {
|
|
278
|
+
const full = join(dir, name);
|
|
279
|
+
const [input, isTS] = readFixture(full);
|
|
280
|
+
|
|
281
|
+
const progress = createProgress();
|
|
282
|
+
const [[result]] = await Promise.all([
|
|
283
|
+
once(progress, 'file'),
|
|
284
|
+
putout(input, {
|
|
285
|
+
progress,
|
|
286
|
+
printer: getPrinter(),
|
|
287
|
+
isTS,
|
|
288
|
+
...options,
|
|
289
|
+
}),
|
|
290
|
+
]);
|
|
291
|
+
|
|
292
|
+
return t.deepEqual(result, expected);
|
|
293
|
+
};
|
|
294
|
+
|
|
273
295
|
const transform = currify((dir, options, t, name, transformed = null, addons = {}) => {
|
|
274
296
|
const {plugins} = options;
|
|
275
297
|
const full = join(dir, name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/test",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Test runner for 🐊Putout plugins ",
|
|
@@ -40,7 +40,9 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@putout/engine-processor": "*",
|
|
43
|
+
"@putout/engine-runner": "*",
|
|
43
44
|
"@putout/eslint": "^2.0.0",
|
|
45
|
+
"@putout/plugin-filesystem": "*",
|
|
44
46
|
"currify": "^4.0.0",
|
|
45
47
|
"putout": "*",
|
|
46
48
|
"supertape": "^9.0.0",
|