@putout/test 5.2.0 → 5.3.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
@@ -32,7 +32,7 @@ To write test for your plugins you need initialize `test` using `createTest`:
32
32
 
33
33
  ```js
34
34
  import {createTest} from '@putout/test';
35
- const rmVars = require('@putout/plugin-remove-unused-variables');
35
+ import rmVars from '@putout/plugin-remove-unused-variables';
36
36
 
37
37
  const test = createTest(import.meta.url, {
38
38
  'remove-unused-variables': rmVars,
@@ -316,7 +316,7 @@ test('test: eslint: noProcess', async ({noProcess}) => {
316
316
  });
317
317
  ```
318
318
 
319
- ### `comparePlaces(filename, places)`
319
+ ### `comparePlaces(filename, places[, overrides])`
320
320
 
321
321
  ```js
322
322
  test('eslint-config: operator-line-break', async ({comparePlaces}) => {
@@ -331,6 +331,27 @@ test('eslint-config: operator-line-break', async ({comparePlaces}) => {
331
331
  });
332
332
  ```
333
333
 
334
+ with `overrides`:
335
+
336
+ ```js
337
+ test('eslint-config: operator-line-break', async ({comparePlaces}) => {
338
+ const overrides = {
339
+ extends: [
340
+ 'plugin:putout/safe',
341
+ ],
342
+ };
343
+
344
+ await comparePlaces('operator-linebreak', [{
345
+ message: 'There should be no line break before or after \'=\'.',
346
+ position: {
347
+ column: 1,
348
+ line: 2,
349
+ },
350
+ rule: 'operator-linebreak (eslint)',
351
+ }], overrides);
352
+ });
353
+ ```
354
+
334
355
  ## Processors API
335
356
 
336
357
  With `processors api` you can test `processors` in a simplest possible way.
@@ -338,9 +359,9 @@ With `processors api` you can test `processors` in a simplest possible way.
338
359
  First things first, init `test` with:
339
360
 
340
361
  ```js
341
- const {createTest} = require('@putout/test/processor');
362
+ import {createTest} from '@putout/test/processor';
342
363
 
343
- const test = createTest(__dirname, {
364
+ const test = createTest(import.meta.url, {
344
365
  extension: 'json',
345
366
  processors: [
346
367
  'json',
@@ -59,14 +59,17 @@ export const createTest = (url) => {
59
59
 
60
60
  return operator.equal(source, code);
61
61
  },
62
- comparePlaces: (operator) => async (name, expected) => {
62
+ comparePlaces: (operator) => async (name, expected, override) => {
63
63
  const full = join(fixtureDir, name);
64
64
  const [resolvedName, code] = await read(full);
65
65
 
66
66
  const [, places] = await eslint({
67
- config,
68
67
  name: resolvedName,
69
68
  code,
69
+ config: {
70
+ ...config,
71
+ ...override,
72
+ },
70
73
  });
71
74
 
72
75
  return operator.deepEqual(places, expected);
package/lib/test.js CHANGED
@@ -381,7 +381,7 @@ const reportCode = currify(({plugins, rules, isTS}, t, source, message) => {
381
381
  const resultMessages = places.map(getMessage);
382
382
 
383
383
  if (isArray(message))
384
- return t.deepEqual(resultMessages, message, 'should equal');
384
+ return t.deepEqual(resultMessages, message);
385
385
 
386
386
  return t.equal(resultMessages[0], message);
387
387
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/test",
3
- "version": "5.2.0",
3
+ "version": "5.3.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 ",
@@ -65,7 +65,7 @@
65
65
  "eslint": "^8.0.1",
66
66
  "eslint-plugin-node": "^11.0.0",
67
67
  "eslint-plugin-putout": "^15.0.0",
68
- "lerna": "^4.0.0",
68
+ "lerna": "^5.0.0",
69
69
  "madrun": "^9.0.0",
70
70
  "mock-require": "^3.0.3",
71
71
  "nodemon": "^2.0.1"