@putout/test 4.0.1 → 4.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 +29 -1
- package/lib/test.js +5 -2
- package/lib/test.mjs +9 -0
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/test.svg?style=flat&longCache=true
|
|
4
4
|
[NPMURL]: https://npmjs.org/package/@putout/test "npm"
|
|
5
5
|
|
|
6
|
-
Test runner for [
|
|
6
|
+
Test runner for 🐊[`Putout`](https://github.com/coderaiser/putout#plugins-api). Basically it is [supercharged `tape`](https://github.com/coderaiser/supertape) with aditional asseritions:
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -21,6 +21,21 @@ UPDATE=1 tape test/*.js
|
|
|
21
21
|
|
|
22
22
|
## Plugins API
|
|
23
23
|
|
|
24
|
+
All plugins 🐊`Putout` plugins written in `CommonJS`, since `ESLint` written on `CommonJS` and we have a huge `ESLint`-based ecosystem wich is good to reuse.
|
|
25
|
+
`🐊`Putout`can be used in all IDE's supported by`ESLint` as [`eslint-plugin-putout`](https://github.com/coderaiser/putout/tree/packages/eslint-plugin-putout).
|
|
26
|
+
When [async rules will be supported](https://github.com/eslint/eslint/issues/15394) we can switch to `ESM`.
|
|
27
|
+
|
|
28
|
+
To write test for your plugins you need initialize `test` using `createTest`:
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
import {createTest} from '@putout/test';
|
|
32
|
+
const rmVars = require('@putout/plugin-remove-unused-variables');
|
|
33
|
+
|
|
34
|
+
const test = createTest(import.meta.url, {
|
|
35
|
+
'remove-unused-variables': rmVars,
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
24
39
|
### `report(filename, message | []messages)`
|
|
25
40
|
|
|
26
41
|
checks error message (or messages) of a plugin
|
|
@@ -168,6 +183,19 @@ test('plugin-apply-numeric-separators: no transform: hex', (t) => {
|
|
|
168
183
|
});
|
|
169
184
|
```
|
|
170
185
|
|
|
186
|
+
## Formatters API
|
|
187
|
+
|
|
188
|
+
First you need to create test with:
|
|
189
|
+
|
|
190
|
+
```js
|
|
191
|
+
import {createTest} from '@putout/test';
|
|
192
|
+
import rmVars from '@putout/plugin-remove-unused-variables';
|
|
193
|
+
|
|
194
|
+
const test = createTest(import.meta.url, {
|
|
195
|
+
'remove-unused-variables': rmVars,
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
171
199
|
### `format(formatter, filename)`
|
|
172
200
|
|
|
173
201
|
check file name formatting (pass `process.env.UPDATE=1` to save fixture)
|
package/lib/test.js
CHANGED
|
@@ -42,7 +42,10 @@ const readFixture = (name) => {
|
|
|
42
42
|
return [readFileSync(`${name}.js`, 'utf8'), TS.DISABLED];
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
module.exports =
|
|
45
|
+
module.exports = createTest;
|
|
46
|
+
module.exports.createTest = createTest;
|
|
47
|
+
|
|
48
|
+
function createTest(dir, plugin, rules) {
|
|
46
49
|
const update = isUpdate();
|
|
47
50
|
|
|
48
51
|
dir = join(dir, 'fixture');
|
|
@@ -75,7 +78,7 @@ module.exports = (dir, plugin, rules) => {
|
|
|
75
78
|
formatMany: (update ? formatManySave : formatMany)({dir, plugins, rules}),
|
|
76
79
|
noFormat: noFormat({dir, plugins, rules}),
|
|
77
80
|
});
|
|
78
|
-
}
|
|
81
|
+
}
|
|
79
82
|
|
|
80
83
|
const format = currify(({dir, plugins, rules}, t) => async (formatter, name, formatterOptions = {}) => {
|
|
81
84
|
const full = join(dir, name);
|
package/lib/test.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/test",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
5
5
|
"description": "test runner for putout plugins ",
|
|
6
6
|
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/test#readme",
|
|
@@ -9,8 +9,12 @@
|
|
|
9
9
|
"tape": "bin/test.mjs"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
|
-
".":
|
|
13
|
-
|
|
12
|
+
".": {
|
|
13
|
+
"require": "./lib/test.js",
|
|
14
|
+
"import": "./lib/test.mjs"
|
|
15
|
+
},
|
|
16
|
+
"./processor": "./lib/processor/index.js",
|
|
17
|
+
"./formatter": "./lib/formatter/index.mjs"
|
|
14
18
|
},
|
|
15
19
|
"release": false,
|
|
16
20
|
"tag": false,
|
|
@@ -33,6 +37,7 @@
|
|
|
33
37
|
"@putout/engine-processor": "*",
|
|
34
38
|
"currify": "^4.0.0",
|
|
35
39
|
"putout": "*",
|
|
40
|
+
"simport": "^1.2.0",
|
|
36
41
|
"supertape": "^6.0.0",
|
|
37
42
|
"try-catch": "^3.0.0"
|
|
38
43
|
},
|
|
@@ -58,8 +63,7 @@
|
|
|
58
63
|
"lerna": "^4.0.0",
|
|
59
64
|
"madrun": "^8.0.1",
|
|
60
65
|
"mock-require": "^3.0.3",
|
|
61
|
-
"nodemon": "^2.0.1"
|
|
62
|
-
"simport": "^1.2.0"
|
|
66
|
+
"nodemon": "^2.0.1"
|
|
63
67
|
},
|
|
64
68
|
"license": "MIT",
|
|
65
69
|
"engines": {
|