supertape 6.12.0 → 7.0.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,31 @@
1
+ 2022.02.14, v7.0.0
2
+
3
+ fix:
4
+ - chore(actions) add ability to fix
5
+
6
+ feature:
7
+ - supertape: check-scopes, check-assertions-count: enable by default
8
+
9
+
10
+ 2022.01.15, v6.13.1
11
+
12
+ fix:
13
+ - (supertape) revert: add exit code 5 for skip"
14
+
15
+
16
+ 2022.01.15, v6.13.0
17
+
18
+ feature:
19
+ - (supertape) add exit code 5 for skip
20
+ - (@supertape/operator-stub) notCalled: no arg
21
+
22
+
23
+ 2022.01.14, v6.12.1
24
+
25
+ fix:
26
+ - (@supertape) engine-loader: windows support
27
+ - (supertape) windows support
28
+
1
29
  2022.01.14, v6.12.0
2
30
 
3
31
  feature:
package/README.md CHANGED
@@ -1,19 +1,25 @@
1
- # 📼 `Supertape` [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
1
+ # 📼 Supertape [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
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/supertape/actions?query=workflow%3A%22Node+CI%22 "Build Status"
6
- [BuildStatusIMGURL]: https://github.com/coderaiser/supertape/workflows/Node%20CI/badge.svg
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
7
+ [BuildStatusURL]: https://travis-ci.org/coderaiser/supertape "Build Status"
7
8
  [CoverageURL]: https://coveralls.io/github/coderaiser/supertape?branch=master
8
9
  [CoverageIMGURL]: https://coveralls.io/repos/coderaiser/supertape/badge.svg?branch=master&service=github
9
10
 
10
- [Tape](https://github.com/substack/tape) compatible [TAP](https://testanything.org/) test runner with superpowers. Contains:
11
+ [![supertape](https://asciinema.org/a/Cgc3rDOfZAeDnJSxzEYpPfBMY.svg)](https://asciinema.org/a/Cgc3rDOfZAeDnJSxzEYpPfBMY)
12
+
13
+ [Tape](https://github.com/substack/tape)-inspired [TAP](https://testanything.org/)-compatible simplest high speed test runner with superpowers.
14
+
15
+ 📼`Supertape` written from scratch after messing a lot with `tape`, it willing to be compatible with it as much as possible.
16
+ and has a couple differences. It contains:
11
17
 
12
18
  - ability to work with [esm modules](https://nodejs.org/api/esm.html) (take a look at [mock-import](https://github.com/coderaiser/mock-import) for mocking).
13
19
  - shows colored diff when test not `equal` or not `deepEqual`;
14
20
  - produces deteiled stack traces for `async functions`;
15
- - as many `only` as you wish
16
- - ability to extend
21
+ - as many `only` as you wish;
22
+ - ability to extend;
17
23
  - smart timeouts for long running tests 🏃‍♂️(configured with `SUPERTAPE_TIMEOUT`);
18
24
  - more natural assertions: `expected, result` -> `result, expected`, for example:
19
25
 
@@ -27,8 +33,6 @@ Doesn't contain:
27
33
  - aliases, methods list much shorter;
28
34
  - `throws`, `doesNotThrows` - use [tryCatch](https://github.com/coderaiser/try-catch), [tryToCatch](https://github.com/coderaiser/try-to-catch) with `equal` instead.
29
35
 
30
- `Supertape` was written from scratch after messing a lot with `tape`, it inspired by `tape` and willing to be compatible with it.
31
-
32
36
  ## Install
33
37
 
34
38
  ```
@@ -44,8 +48,8 @@ Options
44
48
  -v, --version output version information and exit
45
49
  -f, --format use a specific output format - default: progress-bar/tap on CI
46
50
  -r, --require require module
47
- --check-scopes check that messages contains scope: 'scope: message'
48
- --check-assertions-count check that assertion count is no more then 1
51
+ --no-check-scopes do not check that messages contains scope: 'scope: message'
52
+ --no-check-assertions-count do not check that assertion count is no more then 1
49
53
  --no-check-duplicates do not check messages for duplicates
50
54
  ```
51
55
 
@@ -63,20 +67,74 @@ test('tape: error', (t) => {
63
67
  });
64
68
  ```
65
69
 
66
- ## Codemod
70
+ ## 🤷 How to migrate from `tape`?
71
+
72
+ You can convert your codebase from `tape` to 📼`Supertape` with help of 🐊[`Putout`](https://github.com/coderaiser/putout), which has built-in [@putout/plugin-tape](https://github.com/coderaiser/putout/tree/master/packages/plugin-tape),
73
+ which has a lot of rules that helps to write tests.
74
+ Here is [result example](https://github.com/coderaiser/cloudcmd/commit/74d56f795d22e98937dce0641ee3c7514a79e9e6).
75
+
76
+ ## `ESLint` rules
77
+
78
+ [`eslint-plugin-putout`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#readme) has rules for 📼`Supertape`:
79
+
80
+ - ✅ [`remove-newline-before-t-end`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout/lib/tape-remove-newline-before-t-end#readme)
81
+ - ✅ [`add-newline-before-assertion`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout/lib/tape-add-newline-before-assertion#readme)
82
+ - ✅ [`add-newline-between-tests`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout/lib/tape-add-newline-between-tests#readme)
83
+
84
+ ## Operators
85
+
86
+ To simplify `supertape` core operators located in separate packages, called `operators`:
87
+
88
+ Here is a list of built-int operators:
89
+
90
+ | Package | Version |
91
+ |--------|-------|
92
+ | [`@supertape/operator-stub`](/packages/operator-stub) | [![npm](https://img.shields.io/npm/v/@supertape/operator-stub.svg?maxAge=86400)](https://www.npmjs.com/package/@supertape/operator-stub) |
93
+
94
+ ## Formatters
67
95
 
68
- 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).
69
- Here is [example of a result](https://github.com/coderaiser/cloudcmd/commit/74d56f795d22e98937dce0641ee3c7514a79e9e6).
96
+ There is a list of built-int `formatters` to customize output:
97
+
98
+ | Package | Version |
99
+ |--------|-------|
100
+ | [`@supertape/formatter-tap`](/packages/formatter-tap) | [![npm](https://img.shields.io/npm/v/@supertape/formatter-tap.svg?maxAge=86400)](https://www.npmjs.com/package/@supertape/formatter-tap) |
101
+ | [`@supertape/formatter-fail`](/packages/formatter-fail) | [![npm](https://img.shields.io/npm/v/@supertape/formatter-fail.svg?maxAge=86400)](https://www.npmjs.com/package/@supertape/formatter-fail) |
102
+ | [`@supertape/formatter-short`](/packages/formatter-short) | [![npm](https://img.shields.io/npm/v/@supertape/formatter-short.svg?maxAge=86400)](https://www.npmjs.com/package/@supertape/formatter-short) |
103
+ | [`@supertape/formatter-progress-bar`](/packages/formatter-progress-bar) | [![npm](https://img.shields.io/npm/v/@supertape/formatter-progress-bar.svg?maxAge=86400)](https://www.npmjs.com/package/@supertape/formatter-progress-bar) |
104
+ | [`@supertape/formatter-json-lines`](/packages/formatter-json-lines) | [![npm](https://img.shields.io/npm/v/@supertape/formatter-json-lines.svg?maxAge=86400)](https://www.npmjs.com/package/@supertape/formatter-json-lines) |
70
105
 
71
106
  ## API
72
107
 
73
108
  ### Methods
74
109
 
75
- The assertion methods in `supertape` are heavily influenced or copied from the methods
76
- in [tape](https://github.com/substack/tape).
110
+ The assertion methods in `supertape` are heavily influenced by [tape](https://github.com/substack/tape).
77
111
 
78
112
  ```js
79
113
  const test = require('supertape');
114
+ const {sum} = require('./calc.js');
115
+
116
+ test('calc: sum', (t) => {
117
+ const result = sum(1, 2);
118
+ const expected = 3;
119
+
120
+ t.equal(result, expected);
121
+ t.end();
122
+ });
123
+ ```
124
+
125
+ or in `ESM`:
126
+
127
+ ```js
128
+ import {test} from 'supertape';
129
+ import {sum} from './calc.js';
130
+
131
+ test('calc: sum', (t) => {
132
+ const result = sum(1, 2);
133
+ const expected = 3;
134
+
135
+ t.equal(result, expected);
136
+ t.end();
137
+ });
80
138
  ```
81
139
 
82
140
  ## test(name, cb)
@@ -176,9 +234,8 @@ const test = require('supertape');
176
234
 
177
235
  test('lib: arguments', async (t) => {
178
236
  throw Error('hello');
179
- // will call t.fail() with an error
180
- // will call t.end()
181
- t.end();
237
+ // will call t.fail with an error
238
+ // will call t.end
182
239
  });
183
240
 
184
241
  test('lib: diff', (t) => {
package/help.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "-v, --version ": "output version information and exit",
4
4
  "-f, --format ": "use a specific output format - default: progress-bar/tap on CI",
5
5
  "-r, --require ": "require module",
6
- "--check-scopes ": "check that messages contains scope: 'scope: message'",
7
- "--check-assertions-count ": "check that assertion count is no more then 1",
6
+ "--no-check-scopes ": "do not check that messages contains scope: 'scope: message'",
7
+ "--no-check-assertions-count": "do not check that assertion count is no more then 1",
8
8
  "--no-check-duplicates ": "do not check messages for duplicates"
9
9
  }
package/lib/cli.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const {resolve: resolvePath} = require('path');
4
4
  const {once} = require('events');
5
+ const {pathToFileURL} = require('url');
5
6
 
6
7
  const yargsParser = require('yargs-parser');
7
8
  const glob = require('glob');
@@ -166,7 +167,9 @@ async function cli({argv, cwd, stdout, isStop}) {
166
167
  const files = removeDuplicates(allFiles);
167
168
 
168
169
  for (const file of files) {
169
- promises.push(simpleImport(resolvePath(cwd, file)));
170
+ // always resolve before import for windows
171
+ const resolved = pathToFileURL(resolvePath(cwd, file));
172
+ promises.push(simpleImport(resolved));
170
173
  }
171
174
 
172
175
  filesCount(files.length);
package/lib/supertape.js CHANGED
@@ -34,8 +34,8 @@ const defaultOptions = {
34
34
  isStop: () => false,
35
35
  checkDuplicates: true,
36
36
  checkIfEnded: true,
37
- checkAssertionsCount: false,
38
- checkScopes: false,
37
+ checkAssertionsCount: true,
38
+ checkScopes: true,
39
39
  };
40
40
 
41
41
  function _createEmitter({quiet, format, getOperators, isStop}) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "supertape",
3
- "version": "6.12.0",
3
+ "version": "7.0.0",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
- "description": "📼 Supertape fastest simplest test runner with lots of formatters",
5
+ "description": "📼 Supertape simplest high speed test runner with superpowers",
6
6
  "homepage": "http://github.com/coderaiser/supertape",
7
7
  "main": "./lib/supertape.js",
8
8
  "exports": {