From 4b18b7bb39f560d5f08a13836a608db7449e20b6 Mon Sep 17 00:00:00 2001 From: busticated Date: Fri, 31 Jul 2026 11:33:30 -0700 Subject: [PATCH 1/3] fix tests - timer ids can be numbers or objects depending on context --- packages/periodical/src/index.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/periodical/src/index.test.ts b/packages/periodical/src/index.test.ts index 7c51a33..7754c02 100644 --- a/packages/periodical/src/index.test.ts +++ b/packages/periodical/src/index.test.ts @@ -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); }); @@ -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); }); @@ -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); }); From f75d7ad09f252300c9f708c5223043784288c3e2 Mon Sep 17 00:00:00 2001 From: busticated Date: Fri, 31 Jul 2026 13:35:07 -0700 Subject: [PATCH 2/3] work-around for node 20's sourcemaps issue w/ code coverage --- DEVELOPMENT.md | 10 +++++++++- bin/templates/package.json.tmpl | 3 ++- package.json | 1 + packages/numeric-id-hasher/package.json | 3 ++- packages/periodical/package.json | 3 ++- packages/timer/package.json | 3 ++- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index e826770..c25be76 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -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.

@@ -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))_ - diff --git a/bin/templates/package.json.tmpl b/bin/templates/package.json.tmpl index 9b0d4f4..83f1f3f 100644 --- a/bin/templates/package.json.tmpl +++ b/bin/templates/package.json.tmpl @@ -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/*", diff --git a/package.json b/package.json index 78626cd..fc31765 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/numeric-id-hasher/package.json b/packages/numeric-id-hasher/package.json index 9313983..b9adf43 100644 --- a/packages/numeric-id-hasher/package.json +++ b/packages/numeric-id-hasher/package.json @@ -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/*", diff --git a/packages/periodical/package.json b/packages/periodical/package.json index cd23c3c..5fd5b08 100644 --- a/packages/periodical/package.json +++ b/packages/periodical/package.json @@ -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/*", diff --git a/packages/timer/package.json b/packages/timer/package.json index 9076dfb..960b958 100644 --- a/packages/timer/package.json +++ b/packages/timer/package.json @@ -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/*", From cea4c1a3ddc7a2f939fba774a5996878e469bb3c Mon Sep 17 00:00:00 2001 From: busticated Date: Sun, 2 Aug 2026 14:23:49 -0700 Subject: [PATCH 3/3] bump github actions deps to latest, tune node.js version targeting, drop node v18 --- .github/workflows/ci.yaml | 2 +- .github/workflows/publish.yaml | 12 +++++++++--- .github/workflows/test.yaml | 17 ++++++----------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 87fef03..80c018f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 8a546cb..34b389f 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -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 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3c7e588..7a23fbf 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,9 +2,6 @@ name: Test on: workflow_call: - secrets: - NPM_TOKEN: - required: true jobs: test: @@ -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 }} -