@reporters/bail 1.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.md +8 -0
- package/README.md +24 -0
- package/index.js +8 -0
- package/package.json +22 -0
- package/tests/fixtures/fail.js +7 -0
- package/tests/fixtures/pass.js +3 -0
- package/tests/index.test.js +24 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/@reporters/bail)  [](https://codecov.io/gh/MoLow/reporters)
|
|
2
|
+
|
|
3
|
+
# `node:test` Bail on failure
|
|
4
|
+
A package to bail on the first test failure of a test run
|
|
5
|
+
using node built in test runner.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save-dev @reporters/bail
|
|
11
|
+
```
|
|
12
|
+
or
|
|
13
|
+
```bash
|
|
14
|
+
yarn add --dev @reporters/bail
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
node --test \
|
|
21
|
+
--test-reporter=@reporters/bail --test-reporter-destination=stderr \
|
|
22
|
+
--test-reporter=spec --test-reporter-destination=stdout
|
|
23
|
+
```
|
|
24
|
+
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reporters/bail",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A Bail library for `node:test`",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"node:test",
|
|
7
|
+
"test",
|
|
8
|
+
"reporter",
|
|
9
|
+
"reporters"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=../github/index.js --test-reporter-destination=stdout --test"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/MoLow/reporters/issues"
|
|
16
|
+
},
|
|
17
|
+
"main": "index.js",
|
|
18
|
+
"homepage": "https://github.com/MoLow/reporters/tree/main/packages/bail",
|
|
19
|
+
"repository": "https://github.com/MoLow/reporters.git",
|
|
20
|
+
"author": "Moshe Atlow",
|
|
21
|
+
"license": "MIT"
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const { test } = require('node:test');
|
|
2
|
+
const { spawnSync } = require('child_process');
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
|
|
5
|
+
test('pass should not interfere with passing test', () => {
|
|
6
|
+
const child = spawnSync(process.execPath, [
|
|
7
|
+
'--test-reporter', 'dot', '--test-reporter-destination', 'stdout',
|
|
8
|
+
'--test-reporter', './index.js', '--test-reporter-destination', 'stdout', 'tests/fixtures/pass.js',
|
|
9
|
+
], { env: {} });
|
|
10
|
+
assert.strictEqual(child.stderr?.toString(), '');
|
|
11
|
+
assert.strictEqual(child.stdout?.toString(), '.\n');
|
|
12
|
+
assert.strictEqual(child.status, 0);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('fail should stop after failed test', () => {
|
|
16
|
+
const child = spawnSync(process.execPath, [
|
|
17
|
+
'--test-reporter', 'dot', '--test-reporter-destination', 'stdout',
|
|
18
|
+
'--test-reporter', './index.js', '--test-reporter-destination', 'stdout',
|
|
19
|
+
'tests/fixtures/fail.js', 'tests/fixtures/pass.js',
|
|
20
|
+
], { env: {} });
|
|
21
|
+
assert.strictEqual(child.stderr?.toString(), '');
|
|
22
|
+
assert.strictEqual(child.stdout?.toString(), 'X\n\x1B[31m✖ Bailing on failed test: fail\x1B[0m\n');
|
|
23
|
+
assert.strictEqual(child.status, 1);
|
|
24
|
+
});
|