Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
tags: ${{ steps.info.outputs.tags }}
steps:
- name: Checkout Source Code
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
fetch-tags: true
- name: Set Info
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ on:
NPM_TOKEN:
required: true

permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: 20
node-version: 'lts/*'
check-latest: true
registry-url: 'https://registry.npmjs.org'
package-manager-cache: false
- name: Install Dependencies
uses: bahmutov/npm-install@v1
- name: Upload to NPM
Expand Down
17 changes: 6 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: Test

on:
workflow_call:
secrets:
NPM_TOKEN:
required: true

jobs:
test:
Expand All @@ -19,27 +16,25 @@ jobs:
architecture:
- x64
node_version:
- 18
- 20
- 'lts/-1'
- 'lts/*'
experimental:
- false
include:
- node_version: 21
- node_version: 'latest'
experimental: true
os: ubuntu-latest
architecture: x64
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node_version }}
architecture: ${{ matrix.architecture }}
check-latest: true
- name: Install Dependencies
uses: bahmutov/npm-install@v1
- name: Run tests
run: npm test
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

10 changes: 9 additions & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ e.g.
npm test -- --workspace packages/timer
```

To run tests _with_ code coverage reporting:

```shell
npm run test:coverage
```

> [!NOTE]
> 🐛 Node's `--experimental-test-coverage` can throw on some older Node versions when reporting coverage for source-mapped TypeScript builds ([nodejs/node#51552](https://github.com/nodejs/node/issues/51552)) - this will be fixed in a future update.

Run `npm run` to see other test-related commands, if available.

</p>
Expand Down Expand Up @@ -324,4 +333,3 @@ Packages are published from the `main` branch via CI/CD after peer review. To re

> [!CAUTION]
> Avoid editing `git` history (`rebase`, etc) once the release commit is made - this will nullify the generated tags ([docs](https://git-scm.com/docs/git-tag#_on_re_tagging))_

3 changes: 2 additions & 1 deletion bin/templates/package.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"scripts": {
"version": "npm run changelog:update && npm run docs:build",
"prepare": "npm run build",
"test": "npm run build && NODE_V8_COVERAGE=tmp/coverage node --test --test-reporter spec --experimental-test-coverage --enable-source-maps dist/esm/*.test.js",
"test": "npm run build && node --test --test-reporter spec --enable-source-maps dist/esm/*.test.js",
"test:coverage": "npm run build && NODE_V8_COVERAGE=tmp/coverage node --test --test-reporter spec --experimental-test-coverage --enable-source-maps dist/esm/*.test.js",
"typecheck": "tsc --project .tshy/esm.json --noemit",
"build": "tshy",
"clean": "rm -rf ./dist && rm -rf ./tmp/*",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"scripts": {
"start": "echo \"Error: no source code available\" && exit 1",
"test": "npm run lint && npm run typecheck && npm run test --workspaces",
"test:coverage": "npm run lint && npm run typecheck && npm run test:coverage --workspaces",
"lint": "eslint . --ext .js,.jsx,.mjs,.ts,.tsx --ignore-path .gitignore",
"lint:fix": "npm run lint -- --fix",
"typecheck": "npm run typecheck --workspaces",
Expand Down
3 changes: 2 additions & 1 deletion packages/numeric-id-hasher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"scripts": {
"version": "npm run changelog:update && npm run docs:build",
"prepare": "npm run build",
"test": "npm run build && NODE_V8_COVERAGE=tmp/coverage node --test --test-reporter spec --experimental-test-coverage --enable-source-maps dist/esm/*.test.js",
"test": "npm run build && node --test --test-reporter spec --enable-source-maps dist/esm/*.test.js",
"test:coverage": "npm run build && NODE_V8_COVERAGE=tmp/coverage node --test --test-reporter spec --experimental-test-coverage --enable-source-maps dist/esm/*.test.js",
"typecheck": "tsc --noemit",
"build": "tshy",
"clean": "rm -rf ./dist && rm -rf ./tmp/*",
Expand Down
3 changes: 2 additions & 1 deletion packages/periodical/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"scripts": {
"version": "npm run changelog:update && npm run docs:build",
"prepare": "npm run build",
"test": "npm run build && NODE_V8_COVERAGE=tmp/coverage node --test --test-reporter spec --experimental-test-coverage --enable-source-maps dist/esm/*.test.js",
"test": "npm run build && node --test --test-reporter spec --enable-source-maps dist/esm/*.test.js",
"test:coverage": "npm run build && NODE_V8_COVERAGE=tmp/coverage node --test --test-reporter spec --experimental-test-coverage --enable-source-maps dist/esm/*.test.js",
"typecheck": "tsc --noemit",
"build": "tshy",
"clean": "rm -rf ./dist && rm -rf ./tmp/*",
Expand Down
6 changes: 3 additions & 3 deletions packages/periodical/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('@bust/periodically', () => {
ctx.mock.timers.tick(interval);

assert.equal(myObj.value, 1);
assert.equal(typeof p.timeoutId, 'number');
assert.notEqual(p.timeoutId, undefined);
assert.equal(p.isRunning(), true);
});

Expand All @@ -49,7 +49,7 @@ describe('@bust/periodically', () => {
ctx.mock.timers.tick(interval);

assert.equal(run.mock.callCount(), 1);
assert.equal(typeof p.timeoutId, 'number');
assert.notEqual(p.timeoutId, undefined);
assert.equal(p.isRunning(), true);
});

Expand Down Expand Up @@ -78,7 +78,7 @@ describe('@bust/periodically', () => {

assert.equal(run.mock.callCount(), 1);
assert.notEqual(p.fn, noop);
assert.equal(typeof p.timeoutId, 'number');
assert.notEqual(p.timeoutId, undefined);
assert.equal(p.isRunning(), true);
});

Expand Down
3 changes: 2 additions & 1 deletion packages/timer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"scripts": {
"version": "npm run changelog:update && npm run docs:build",
"prepare": "npm run build",
"test": "npm run build && NODE_V8_COVERAGE=tmp/coverage node --test --test-reporter spec --experimental-test-coverage --enable-source-maps dist/esm/*.test.js",
"test": "npm run build && node --test --test-reporter spec --enable-source-maps dist/esm/*.test.js",
"test:coverage": "npm run build && NODE_V8_COVERAGE=tmp/coverage node --test --test-reporter spec --experimental-test-coverage --enable-source-maps dist/esm/*.test.js",
"typecheck": "tsc --noemit",
"build": "tshy",
"clean": "rm -rf ./dist && rm -rf ./tmp/*",
Expand Down