@putout/test 4.0.0 → 4.0.1

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.
Files changed (3) hide show
  1. package/README.md +20 -20
  2. package/lib/test.js +25 -4
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -21,7 +21,7 @@ UPDATE=1 tape test/*.js
21
21
 
22
22
  ## Plugins API
23
23
 
24
- ### report(filename, message | []messages)
24
+ ### `report(filename, message | []messages)`
25
25
 
26
26
  checks error message (or messages) of a plugin
27
27
 
@@ -32,7 +32,7 @@ test('remove usless variables: for-of', (t) => {
32
32
  });
33
33
  ```
34
34
 
35
- ### reportCode(input, message)
35
+ ### `reportCode(input, message)`
36
36
 
37
37
  checks error message of a plugin from `input` code
38
38
 
@@ -43,7 +43,7 @@ test('remove debugger: report', (t) => {
43
43
  });
44
44
  ```
45
45
 
46
- ### transform(filename [, output, plugins])
46
+ ### `transform(filename [, output, plugins])`
47
47
 
48
48
  check transform of `filename.js` -> `filename-fix.js` in `test/fixtures` directory
49
49
 
@@ -56,7 +56,7 @@ test('remove usless variables: for-of', (t) => {
56
56
  });
57
57
  ```
58
58
 
59
- ### transformCode(input, output)
59
+ ### `transformCode(input, output)`
60
60
 
61
61
  check transform of `input` -> `output` code
62
62
 
@@ -67,7 +67,7 @@ test('remove-console: property identifier: code', (t) => {
67
67
  });
68
68
  ```
69
69
 
70
- ### reportWithOptions(filename, options)
70
+ ### `reportWithOptions(filename, options)`
71
71
 
72
72
  check report of `filename.js` with `options`
73
73
 
@@ -83,7 +83,7 @@ test('putout: test: reportWithOptions', (t) => {
83
83
  });
84
84
  ```
85
85
 
86
- ### noReportWithOptions(filename, options)
86
+ ### `noReportWithOptions(filename, options)`
87
87
 
88
88
  check no report of `filename.js` with `options`
89
89
 
@@ -98,7 +98,7 @@ test('putout: test: noReportWithOptions', (t) => {
98
98
  });
99
99
  ```
100
100
 
101
- ### transformWithOptions(filename, options)
101
+ ### `transformWithOptions(filename, options)`
102
102
 
103
103
  check transform of `filename.js` with `options`
104
104
 
@@ -111,7 +111,7 @@ test('putout: plugin: declare-undefined-variables: transform: parse', (t) => {
111
111
  });
112
112
  ```
113
113
 
114
- ### noTransformWithOptions(filename, options)
114
+ ### `noTransformWithOptions(filename, options)`
115
115
 
116
116
  When file should not be transformed:
117
117
 
@@ -122,7 +122,7 @@ test('test: declared', (t) => {
122
122
  });
123
123
  ```
124
124
 
125
- ### noTransformWithOptions(filename, options)
125
+ ### `noTransformWithOptions(filename, options)`
126
126
 
127
127
  check transform of `filename.js` with `options`
128
128
 
@@ -135,7 +135,7 @@ test('putout: plugin: declare-undefined-variables: transform: assign: dismiss',
135
135
  });
136
136
  ```
137
137
 
138
- ### noReport(filename)
138
+ ### `noReport(filename)`
139
139
 
140
140
  checks error message of a plugin not produces
141
141
 
@@ -146,9 +146,9 @@ test('plugin-putout: check-replace-code: no report: typescript', (t) => {
146
146
  });
147
147
  ```
148
148
 
149
- ### noReportAfterTransform(filename)
149
+ ### `noReportAfterTransform(filename)`
150
150
 
151
- checks error message of a plugin not produces
151
+ checks error message of a plugin not produced
152
152
 
153
153
  ```js
154
154
  test('test: no report after transform', (t) => {
@@ -157,9 +157,9 @@ test('test: no report after transform', (t) => {
157
157
  });
158
158
  ```
159
159
 
160
- ### noTransform(filename)
160
+ ### `noTransform(filename)`
161
161
 
162
- check transform of `filename.js` produce nothing new
162
+ check transform of `filename.js` produce nothing
163
163
 
164
164
  ```js
165
165
  test('plugin-apply-numeric-separators: no transform: hex', (t) => {
@@ -168,7 +168,7 @@ test('plugin-apply-numeric-separators: no transform: hex', (t) => {
168
168
  });
169
169
  ```
170
170
 
171
- ### format(formatter, filename)
171
+ ### `format(formatter, filename)`
172
172
 
173
173
  check file name formatting (pass `process.env.UPDATE=1` to save fixture)
174
174
 
@@ -178,7 +178,7 @@ test('formatter: codeframe', async ({format}) => {
178
178
  });
179
179
  ```
180
180
 
181
- ### noFormat
181
+ ### `noFormat`
182
182
 
183
183
  check that there is no formatting for for such file
184
184
 
@@ -188,7 +188,7 @@ test('formatter: codeframe: no', async ({noFormat}) => {
188
188
  });
189
189
  ```
190
190
 
191
- ### formatMany(formatter, [filename1, filename2])
191
+ ### `formatMany(formatter, [filename1, filename2])`
192
192
 
193
193
  check file name formatting (pass `process.env.UPDATE=1` to save fixture)
194
194
 
@@ -245,7 +245,7 @@ const test = createTest(__dirname, {
245
245
 
246
246
  ```
247
247
 
248
- ### process(filename [, plugins, ])
248
+ ### `process(filename [, plugins, ])`
249
249
 
250
250
  Example:
251
251
 
@@ -259,7 +259,7 @@ test('putout: processor: json', async ({process}) => {
259
259
  });
260
260
  ```
261
261
 
262
- ### noProcess(filename [, plugins, processors])
262
+ ### `noProcess(filename [, plugins, processors])`
263
263
 
264
264
  Check that filename would not be processed.
265
265
 
@@ -271,7 +271,7 @@ test('putout: process: json: no process', async ({noProcess}) => {
271
271
  });
272
272
  ```
273
273
 
274
- ### comparePlaces(filename, places)
274
+ ### `comparePlaces(filename, places)`
275
275
 
276
276
  ```js
277
277
  test('putout: processor: css: places', async ({comparePlaces}) => {
package/lib/test.js CHANGED
@@ -19,6 +19,15 @@ const {isArray} = Array;
19
19
  const {keys, entries} = Object;
20
20
 
21
21
  const {UPDATE} = process.env;
22
+ global.__putout_test_update = UPDATE;
23
+ global.__putout_test_fs = {
24
+ readFileSync,
25
+ writeFileSync,
26
+ existsSync,
27
+ };
28
+
29
+ const isUpdate = () => UPDATE || global.__putout_test_update;
30
+
22
31
  const TS = {
23
32
  ENABLED: true,
24
33
  DISABLED: false,
@@ -34,6 +43,8 @@ const readFixture = (name) => {
34
43
  };
35
44
 
36
45
  module.exports = (dir, plugin, rules) => {
46
+ const update = isUpdate();
47
+
37
48
  dir = join(dir, 'fixture');
38
49
  const plugins = getPlugins(plugin);
39
50
 
@@ -59,9 +70,9 @@ module.exports = (dir, plugin, rules) => {
59
70
  }),
60
71
 
61
72
  formatSave: formatSave({dir, plugins, rules}),
62
- format: (UPDATE ? formatSave : format)({dir, plugins, rules}),
73
+ format: (update ? formatSave : format)({dir, plugins, rules}),
63
74
  formatManySave: formatManySave({dir, plugins, rules}),
64
- formatMany: (UPDATE ? formatManySave : formatMany)({dir, plugins, rules}),
75
+ formatMany: (update ? formatManySave : formatMany)({dir, plugins, rules}),
65
76
  noFormat: noFormat({dir, plugins, rules}),
66
77
  });
67
78
  };
@@ -143,6 +154,11 @@ const formatMany = currify(({dir, plugins, rules}, t) => async (formatter, names
143
154
  });
144
155
 
145
156
  const formatManySave = currify(({dir, plugins, rules}, t) => async (formatter, names, options = {}) => {
157
+ const {
158
+ existsSync,
159
+ writeFileSync,
160
+ } = global.__putout_test_fs;
161
+
146
162
  const name = `${names.join('-')}-format.js`;
147
163
  const outputName = join(dir, name);
148
164
 
@@ -163,6 +179,11 @@ const formatManySave = currify(({dir, plugins, rules}, t) => async (formatter, n
163
179
  });
164
180
 
165
181
  const formatSave = currify(({dir, plugins, rules}, t) => async (formatter, name, options = {}) => {
182
+ const {
183
+ existsSync,
184
+ writeFileSync,
185
+ } = global.__putout_test_fs;
186
+
166
187
  const full = join(dir, name);
167
188
  const outputName = `${full}-format.js`;
168
189
 
@@ -210,7 +231,7 @@ const transform = currify(({dir, plugins, rules}, t, name, transformed = null, a
210
231
  }],
211
232
  });
212
233
 
213
- if (UPDATE)
234
+ if (isUpdate())
214
235
  writeFileSync(`${full}-fix.js`, code);
215
236
 
216
237
  return t.equal(code, output);
@@ -230,7 +251,7 @@ const transformWithOptions = currify(({dir, plugins}, t, name, options) => {
230
251
 
231
252
  const {code} = putout(input, {isTS, plugins, rules});
232
253
 
233
- if (UPDATE)
254
+ if (isUpdate())
234
255
  writeFileSync(`${full}-fix.js`, code);
235
256
 
236
257
  return t.equal(code, output);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/test",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
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",
@@ -58,7 +58,8 @@
58
58
  "lerna": "^4.0.0",
59
59
  "madrun": "^8.0.1",
60
60
  "mock-require": "^3.0.3",
61
- "nodemon": "^2.0.1"
61
+ "nodemon": "^2.0.1",
62
+ "simport": "^1.2.0"
62
63
  },
63
64
  "license": "MIT",
64
65
  "engines": {