supertape 6.3.0 → 6.6.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/ChangeLog CHANGED
@@ -1,3 +1,34 @@
1
+ 2021.09.16, v6.6.0
2
+
3
+ feature:
4
+ - (supertape) add ability to show path of a duplicate
5
+
6
+
7
+ 2021.09.15, v6.5.0
8
+
9
+ feature:
10
+ - (supertape) add support of file links to WebStorm: at: -> at
11
+
12
+
13
+ 2021.09.15, v6.4.0
14
+
15
+ fix:
16
+ - (supertape) improve at when found duplicates
17
+
18
+ feature:
19
+ - (supertape) add ability to toggle check duplicates with env variables SUPERTAPE_CHECK_DUPLICATES
20
+ - (@supertape/formatter-progress-bar) add support of SUPERTAPE_PROGRESS_BAR_STACK'
21
+
22
+
23
+ 2021.09.15, v6.3.1
24
+
25
+ fix:
26
+ - (supertape) improve at when found duplicates
27
+
28
+ feature:
29
+ - (@supertape/formatter-progress-bar) add support of SUPERTAPE_PROGRESS_BAR_STACK'
30
+
31
+
1
32
  2021.09.14, v6.3.0
2
33
 
3
34
  feature:
package/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  [NPMURL]: https://npmjs.org/package/supertape "npm"
4
4
  [NPMIMGURL]: https://img.shields.io/npm/v/supertape.svg?style=flat&longCache=true
5
- [BuildStatusURL]: https://github.com/coderaiser/putout/actions?query=workflow%3A%22Node+CI%22 "Build Status"
6
- [BuildStatusIMGURL]: https://github.com/coderaiser/putout/workflows/Node%20CI/badge.svg
5
+ [BuildStatusURL]: https://github.com/coderaiser/supertape/actions?query=workflow%3A%22Node+CI%22 "Build Status"
6
+ [BuildStatusIMGURL]: https://github.com/coderaiser/supertape/workflows/Node%20CI/badge.svg
7
7
  [DependencyStatusURL]: https://david-dm.org/coderaiser/supertape?path=packages/supertape "Dependency Status"
8
8
  [DependencyStatusIMGURL]: https://img.shields.io/david/coderaiser/supertape.svg?path=packages/supertape&style=flat&longCache=true
9
9
  [CoverageURL]: https://coveralls.io/github/coderaiser/supertape?branch=master
@@ -49,6 +49,11 @@ Options
49
49
  --no-check-duplicates do not check messages for duplicates
50
50
  ```
51
51
 
52
+ ## Environment variables
53
+
54
+ - `SUPERTAPE_TIMEOUT` - timeout for long running processes;
55
+ - `SUPERTAPE_CHECK_DUPLICATES` - toggle check duplicates;
56
+
52
57
  ## Codemod
53
58
 
54
59
  You can convert your codebase from `tape` to `supertape` with help of a [putout](https://github.com/coderaiser/putout) and built-in [@putout/plugin-tape](https://github.com/coderaiser/putout/tree/master/packages/plugin-tape).
package/lib/cli.js CHANGED
@@ -30,6 +30,8 @@ const maybeArray = (a) => isArray(a) ? a : [a];
30
30
  const removeDuplicates = (a) => Array.from(new Set(a));
31
31
  const filesCount = fullstore(0);
32
32
 
33
+ const {SUPERTAPE_CHECK_DUPLICATES} = process.env;
34
+
33
35
  module.exports = async ({argv, cwd, stdout, stderr, exit}) => {
34
36
  const {isStop} = keypress();
35
37
  const [error, result] = await tryToCatch(cli, {
@@ -94,7 +96,7 @@ const yargsOptions = {
94
96
  default: {
95
97
  format: 'progress-bar',
96
98
  require: [],
97
- checkDuplicates: true,
99
+ checkDuplicates: SUPERTAPE_CHECK_DUPLICATES !== '0',
98
100
  },
99
101
  };
100
102
 
package/lib/duplicator.js CHANGED
@@ -6,6 +6,8 @@ const StackTracey = require('stacktracey');
6
6
  const getMessage = ({message, duplicatesMessage}) => [message, duplicatesMessage];
7
7
  const getMessagesList = (tests) => tests.map(getMessage);
8
8
  const compareMessage = (a) => ([b]) => a === b;
9
+ const getDuplicatesMessage = ([, a]) => a;
10
+
9
11
  const processedList = new Set();
10
12
 
11
13
  module.exports = ({tests}) => (msg) => {
@@ -13,38 +15,35 @@ module.exports = ({tests}) => (msg) => {
13
15
  const duplicates = getMessages(tests).filter(compareMessage(msg));
14
16
 
15
17
  if (duplicates.length < 2)
16
- return '';
18
+ return [];
17
19
 
18
- const [, duplicatesMessage] = duplicates.pop();
20
+ const [duplicatesMessage, duplicateAt] = duplicates.map(getDuplicatesMessage);
19
21
 
20
22
  if (processedList.has(duplicatesMessage))
21
- return '';
23
+ return [];
22
24
 
23
25
  processedList.add(duplicatesMessage);
24
- return duplicatesMessage;
26
+ return [`Duplicate ${duplicatesMessage}`, duplicateAt];
25
27
  };
26
28
 
27
- const messages = new Set();
28
- const CALLS_FROM_TEST = 2;
29
-
30
- module.exports.getDuplicatesMessage = ({message, checkDuplicates}) => {
29
+ module.exports.getDuplicatesMessage = ({checkDuplicates}) => {
31
30
  if (!checkDuplicates)
32
31
  return '';
33
32
 
34
- if (!messages.has(message)) {
35
- messages.add(message);
36
- return '';
37
- }
38
-
33
+ return getFileName();
34
+ };
35
+
36
+ const CALLS_FROM_TEST = 3;
37
+
38
+ function getFileName() {
39
39
  const {items} = new StackTracey(Error());
40
40
 
41
41
  for (const {beforeParse, file} of items.slice(CALLS_FROM_TEST)) {
42
42
  if (file.includes('node_modules'))
43
43
  continue;
44
44
 
45
- return `Duplicate message ${beforeParse}`;
45
+ return beforeParse;
46
46
  }
47
47
 
48
48
  return '';
49
- };
50
-
49
+ }
package/lib/format.js CHANGED
@@ -13,7 +13,7 @@ module.exports.parseAt = (stack, {reason}) => {
13
13
 
14
14
  const line = lines[reason === 'user' ? REASON_USER : REASON_EXCEPTION];
15
15
 
16
- return line.trim().replace('at', 'at:');
16
+ return line.trim();
17
17
  };
18
18
 
19
19
  module.exports.addSpaces = addSpaces;
package/lib/operators.mjs CHANGED
@@ -100,11 +100,12 @@ const pass = (message = '(unnamed assert)') => ({
100
100
  message,
101
101
  });
102
102
 
103
- const fail = (error) => ({
103
+ const fail = (error, at) => ({
104
104
  is: false,
105
105
  stack: error.stack,
106
106
  output: '',
107
107
  message: error,
108
+ at,
108
109
  });
109
110
 
110
111
  const deepEqual = (actual, expected, message = 'should deep equal') => {
@@ -191,6 +192,7 @@ function run(name, {formatter, count, incCount, incPassed, incFailed}, testState
191
192
  actual,
192
193
  output,
193
194
  stack,
195
+ at,
194
196
  } = validate(testState);
195
197
 
196
198
  incCount();
@@ -217,7 +219,7 @@ function run(name, {formatter, count, incCount, incPassed, incFailed}, testState
217
219
  expected,
218
220
  output,
219
221
  errorStack: formatOutput(errorStack),
220
- at: parseAt(errorStack, {reason}),
222
+ at: at || parseAt(errorStack, {reason}),
221
223
  });
222
224
  }
223
225
 
package/lib/run-tests.js CHANGED
@@ -159,10 +159,10 @@ async function runOneTest({message, fn, extensions, formatter, count, total, fai
159
159
  failed: failed(),
160
160
  });
161
161
 
162
- const duplicatesMessage = getDuplicatesMessage(message);
162
+ const [duplicateMessage, duplicateAt] = getDuplicatesMessage(message);
163
163
 
164
- if (duplicatesMessage) {
165
- t.fail(duplicatesMessage);
164
+ if (duplicateAt) {
165
+ t.fail(duplicateMessage, duplicateAt);
166
166
  t.end();
167
167
  }
168
168
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supertape",
3
- "version": "6.3.0",
3
+ "version": "6.6.0",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "tape compatible test runner with superpowers",
6
6
  "homepage": "http://github.com/coderaiser/supertape",