Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into Michael/plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
mikicho committed Jan 27, 2024
2 parents e36a2d2 + 3537ebf commit 459b31c
Show file tree
Hide file tree
Showing 65 changed files with 1,198 additions and 290 deletions.
3 changes: 2 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ignore:
- "scripts/**"
- "scripts/**"
- "**/tests/**"
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = {
env: {
commonjs: true,
Expand All @@ -9,8 +11,11 @@ module.exports = {
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'script',
},
rules: {
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
'capitalized-comments': ['error', 'always', { ignoreConsecutiveComments: true, ignorePattern: 'c8 ignore' }],
strict: ['error', 'safe'],
},
};
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [MoLow]
3 changes: 1 addition & 2 deletions .github/workflows/commitlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Conventional Commit Linter

on:
push:
branches:
- main
branches: [main, release-please--branches--main]
pull_request:

jobs:
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
needs: release-please
if: ${{ needs.release-please.outputs.releases_created }}
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
Expand All @@ -50,6 +53,11 @@ jobs:
node-version: lts/*
registry-url: 'https://registry.npmjs.org'
- run: yarn install
- run: yarn workspace ${{ matrix.package }} publish --access public
- id: package-name
run: |
PACKAGE_NAME=$(node -p "PACKAGE_NAME='${{ matrix.package }}'.split('/')[1]")
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_OUTPUT
- run: npm publish --provenance --access public
working-directory: packages/${{ steps.package-name.outputs.PACKAGE_NAME }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ on:
pull_request:
types: [labeled, opened, synchronize, reopened]
push:
branches: [main]
branches: [main, release-please--branches--main]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
node: [v19, v18, v20.3.0]
node: [v18, v20, v21]
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*

.DS_Store

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"packages/github":"1.2.0","packages/junit":"1.1.0","packages/silent":"1.1.0","packages/bail":"1.0.0","packages/testwatch":"1.1.0"}
{"packages/github":"1.5.4","packages/junit":"1.2.6","packages/silent":"1.2.4","packages/bail":"1.1.4","packages/testwatch":"1.4.3","packages/slow":"1.0.0"}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Available reporters:
- [silent](https://www.npmjs.com/package/@reporters/silent) - a silent reporter
- [bail](https://www.npmjs.com/package/@reporters/bail) - bail on first failure
- [testwatch](https://www.npmjs.com/package/@reporters/testwatch) - An interactive REPL for `node:test` watch mode.
- [slow](https://www.npmjs.com/package/@reporters/slow) - report slow tests
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "reporters",
"version": "1.0.2",
"description": "A collection of reporters for `node:test`",
"type": "commonjs",
"main": "index.js",
"private": true,
"scripts": {
Expand Down
40 changes: 40 additions & 0 deletions packages/bail/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# Changelog

## [1.1.4](https://github.com/MoLow/reporters/compare/bail-v1.1.3...bail-v1.1.4) (2024-01-04)


### Bug Fixes

* **test:** update tests ([#106](https://github.com/MoLow/reporters/issues/106)) ([8c09454](https://github.com/MoLow/reporters/commit/8c09454aeefe41e10f9466fc593ff80408d06c8a))

## [1.1.3](https://github.com/MoLow/reporters/compare/bail-v1.1.2...bail-v1.1.3) (2023-09-26)


### Miscellaneous Chores

* add "type" to package.json ([d8567bd](https://github.com/MoLow/reporters/commit/d8567bdd2a415919dba6ba652d2e33dc233426ce))

## [1.1.2](https://github.com/MoLow/reporters/compare/bail-v1.1.1...bail-v1.1.2) (2023-08-13)


### Miscellaneous Chores

* eslint fixes ([3100c40](https://github.com/MoLow/reporters/commit/3100c40ffe3a3e63afb05991f07bf8dbc23efbc9))

## [1.1.1](https://github.com/MoLow/reporters/compare/bail-v1.1.0...bail-v1.1.1) (2023-07-20)


### Documentation

* update screenshots ([0913bf3](https://github.com/MoLow/reporters/commit/0913bf37ce83a0a240c0f28b59a1647741212612))


### Build System

* exclude redundant files ([032eb2f](https://github.com/MoLow/reporters/commit/032eb2fbb1520b3c259e2a80eb38280826e206ef))

## [1.1.0](https://github.com/MoLow/reporters/compare/bail-v1.0.0...bail-v1.1.0) (2023-07-05)


### Features

* publish with provenance ([6ee1e46](https://github.com/MoLow/reporters/commit/6ee1e46040329edeb0f40f753093b6952984f001))

## 1.0.0 (2023-06-05)


Expand Down
3 changes: 3 additions & 0 deletions packages/bail/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ node --test \
--test-reporter=spec --test-reporter-destination=stdout
```

### Example

![cli](https://raw.githubusercontent.com/MoLow/reporters/dbc82f3e738ac40cc75eafc15946f712ccad9c99/packages/bail/assets/cli.gif)
Binary file added packages/bail/assets/cli.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 129 additions & 0 deletions packages/bail/assets/cli.gif.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# The configurations that used for the recording, feel free to edit them
config:

# Specify a command to be executed
# like `/bin/bash -l`, `ls`, or any other commands
# the default is bash for Linux
# or powershell.exe for Windows
command: bash -l

# Specify the current working directory path
# the default is the current working directory path
cwd: /Users/moshe/repos/reporters/packages/bail

# Export additional ENV variables
env:
recording: true

# Explicitly set the number of columns
# or use `auto` to take the current
# number of columns of your shell
cols: 195

# Explicitly set the number of rows
# or use `auto` to take the current
# number of rows of your shell
rows: 32

# Amount of times to repeat GIF
# If value is -1, play once
# If value is 0, loop indefinitely
# If value is a positive number, loop n times
repeat: 0

# Quality
# 1 - 100
quality: 100

# Delay between frames in ms
# If the value is `auto` use the actual recording delays
frameDelay: auto

# Maximum delay between frames in ms
# Ignored if the `frameDelay` isn't set to `auto`
# Set to `auto` to prevent limiting the max idle time
maxIdleTime: 30000

# The surrounding frame box
# The `type` can be null, window, floating, or solid`
# To hide the title use the value null
# Don't forget to add a backgroundColor style with a null as type
frameBox:
type: floating
title: Terminalizer
style:
border: 0px black solid
# boxShadow: none
# margin: 0px

# Add a watermark image to the rendered gif
# You need to specify an absolute path for
# the image on your machine or a URL, and you can also
# add your own CSS styles
watermark:
imagePath: null
style:
position: absolute
right: 15px
bottom: 15px
width: 100px
opacity: 0.9

# Cursor style can be one of
# `block`, `underline`, or `bar`
cursorStyle: block

# Font family
# You can use any font that is installed on your machine
# in CSS-like syntax
fontFamily: "Monaco, Lucida Console, Ubuntu Mono, Monospace"

# The size of the font
fontSize: 12

# The height of lines
lineHeight: 1

# The spacing between letters
letterSpacing: 0

# Theme
theme:
background: "transparent"
foreground: "#afafaf"
cursor: "#c7c7c7"
black: "#232628"
red: "#fc4384"
green: "#b3e33b"
yellow: "#ffa727"
blue: "#75dff2"
magenta: "#ae89fe"
cyan: "#708387"
white: "#d5d5d0"
brightBlack: "#626566"
brightRed: "#ff7fac"
brightGreen: "#c8ed71"
brightYellow: "#ebdf86"
brightBlue: "#75dff2"
brightMagenta: "#ae89fe"
brightCyan: "#b1c6ca"
brightWhite: "#f9f9f4"

# Records, feel free to edit them
records:
- delay: 0
content: "$ cat tests/fixtures/fail.js"
- delay: 1000
content: "\r\n"
- delay: 107
content: "\e[32mconst\e[39;00m\e[38;2;187;187;187m \e[39m{\e[38;2;187;187;187m \e[39mdescribe,\e[38;2;187;187;187m \e[39mtest\e[38;2;187;187;187m \e[39m}\e[38;2;187;187;187m \e[39m\e[38;2;102;102;102m=\e[39m\e[38;2;187;187;187m \e[39mrequire(\e[31m'node:test'\e[39m);\r\n\e[32mconst\e[39;00m\e[38;2;187;187;187m \e[39massert\e[38;2;187;187;187m \e[39m\e[38;2;102;102;102m=\e[39m\e[38;2;187;187;187m \e[39mrequire(\e[31m'node:assert'\e[39m);\r\n\r\ndescribe(\e[31m'enforce no concurrent tests'\e[39m,\e[38;2;187;187;187m \e[39m{\e[38;2;187;187;187m \e[39mconcurrent\e[38;2;102;102;102m:\e[39m\e[38;2;187;187;187m \e[39m\e[32mfalse\e[39;00m\e[38;2;187;187;187m \e[39m},\e[38;2;187;187;187m \e[39m()\e[38;2;187;187;187m \e[39m=>\e[38;2;187;187;187m \e[39m{\r\n\e[38;2;187;187;187m \e[39mtest(\e[31m'fail'\e[39m,\e[38;2;187;187;187m \e[39m\e[32masync\e[39;00m\e[38;2;187;187;187m \e[39m()\e[38;2;187;187;187m \e[39m=>\e[38;2;187;187;187m \e[39massert.fail());\r\n\e[38;2;187;187;187m \e[39mtest(\e[31m'dont run'\e[39m,\e[38;2;187;187;187m \e[39m\e[32masync\e[39;00m\e[38;2;187;187;187m \e[39m()\e[38;2;187;187;187m \e[39m=>\e[38;2;187;187;187m \e[39m{});\r\n});\r\n"
- delay: 6
content: '$ '
- delay: 1500
content: node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=@reporters/bail --test-reporter-destination=stdout tests/fixtures/fail.js
- delay: 562
content: "\r\n"
- delay: 83
content: "▶ enforce no concurrent tests\r\n \e[31m✖ fail \e[90m(0.607ms)\e[39m\e[39m\r\n AssertionError [ERR_ASSERTION]: Failed\r\n at TestContext.<anonymous> \e[90m(/home/repos/reporters/packages/bail/\e[39mtests/fixtures/fail.js:5:35\e[90m)\e[39m\r\n \e[90m at Test.runInAsyncScope (node:async_hooks:203:9)\e[39m\r\n \e[90m at Test.run (node:internal/test_runner/test:573:25)\e[39m\r\n \e[90m at Test.start (node:internal/test_runner/test:486:17)\e[39m\r\n \e[90m at node:internal/test_runner/test:808:71\e[39m\r\n \e[90m at node:internal/per_context/primordials:481:82\e[39m\r\n at new Promise (<anonymous>)\r\n \e[90m at new SafePromise (node:internal/per_context/primordials:449:29)\e[39m\r\n \e[90m at node:internal/per_context/primordials:481:9\e[39m\r\n at Array.map (<anonymous>) {\r\n generatedMessage: \e[33mtrue\e[39m,\r\n code: \e[32m'ERR_ASSERTION'\e[39m,\r\n actual: \e[90mundefined\e[39m,\r\n expected: \e[90mundefined\e[39m,\r\n operator: \e[32m'fail'\e[39m\r\n }\r\n\r\n\r\n\e[31m✖ Bailing on failed test: fail\e[0m\r\n$ "
- delay: 10000
content: "\r\n"
2 changes: 2 additions & 0 deletions packages/bail/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = async function* bail(source) {
for await (const event of source) {
if (event.type === 'test:fail') {
Expand Down
6 changes: 5 additions & 1 deletion packages/bail/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{
"name": "@reporters/bail",
"version": "1.0.0",
"version": "1.1.4",
"description": "A Bail library for `node:test`",
"type": "commonjs",
"keywords": [
"node:test",
"test",
"reporter",
"reporters"
],
"files": [
"./index.js"
],
"scripts": {
"test": "node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=../github/index.js --test-reporter-destination=stdout --test"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/bail/tests/fixtures/fail.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const { describe, test } = require('node:test');
const assert = require('node:assert');

Expand Down
2 changes: 2 additions & 0 deletions packages/bail/tests/fixtures/pass.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const { test } = require('node:test');

test('pass');
5 changes: 3 additions & 2 deletions packages/bail/tests/index.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const { test } = require('node:test');
const { spawnSync } = require('child_process');
const assert = require('assert');
Expand All @@ -18,7 +20,6 @@ test('fail should stop after failed test', () => {
'--test-reporter', './index.js', '--test-reporter-destination', 'stdout',
'tests/fixtures/fail.js', 'tests/fixtures/pass.js',
], { env: {} });
assert.strictEqual(child.stderr?.toString(), '');
assert.strictEqual(child.stdout?.toString(), 'X\n\x1B[31m✖ Bailing on failed test: fail\x1B[0m\n');
assert.strictEqual(child.status, 1);
assert.strictEqual(child.status, 7);
});
Loading

0 comments on commit 459b31c

Please sign in to comment.