js-logging currently has no automated tests. As the library grows (three appenders already, more on the way), manual verification isn't sustainable. We need a test framework, initial unit tests covering the existing appenders, and a CI workflow to catch regressions before they merge.
What's in scope
Choose and configure a test runner that works with Bun (e.g., bun test, Vitest, or similar)
Set up a test/ directory with at least one test file per log appender (Console, Buffer, Noop)
Add test and test:coverage scripts to package.json
Verify the existing threshold bug (this.threshold && treating 0 as falsy) is caught by a test
Create a Gitea Actions workflow (.gitea/workflows/validate.yml or similar) that runs bun test on push/PR
What's out of scope
100% coverage target — we'll get there incrementally
Integration or E2E tests — unit tests only for this issue
Linting or formatting checks (those can be separate issues)
Acceptance criteria
bun run test runs all unit tests and reports pass/fail
bun run test:coverage reports test coverage
Every existing log appender has at least basic unit tests
A Gitea Actions workflow runs bun test on PRs and reports status
Tests catch the falsy this.threshold edge case for LogLevel.ALL = 0
Related
PR #1: feat: add console, buffer, and noop log appenders
### Problem sheer
`js-logging` currently has no automated tests. As the library grows (three appenders already, more on the way), manual verification isn't sustainable. We need a test framework, initial unit tests covering the existing appenders, and a CI workflow to catch regressions before they merge.
### What's in scope
- Choose and configure a test runner that works with Bun (e.g., `bun test`, Vitest, or similar)
- Set up a `test/` directory with at least one test file per log appender (Console, Buffer, Noop)
- Add `test` and `test:coverage` scripts to `package.json`
- Verify the existing threshold bug (`this.threshold &&` treating 0 as falsy) is caught by a test
- Create a Gitea Actions workflow (`.gitea/workflows/validate.yml` or similar) that runs `bun test` on push/PR
### What's out of scope
- 100% coverage target — we'll get there incrementally
- Integration or E2E tests — unit tests only for this issue
- Linting or formatting checks (those can be separate issues)
### Acceptance criteria
- `bun run test` runs all unit tests and reports pass/fail
- `bun run test:coverage` reports test coverage
- Every existing log appender has at least basic unit tests
- A Gitea Actions workflow runs `bun test` on PRs and reports status
- Tests catch the falsy `this.threshold` edge case for `LogLevel.ALL = 0`
### Related
- PR #1: `feat: add console, buffer, and noop log appenders`
@mahseiah_ai I agree. I think there is only one open questions: Which test runner should we use? This is a very lightweight library. I am leaning towards using bun test to avoid bringing in any additional dependencies. I think that will meet our needs.
Regarding Gitea Actions, in addition to running on PRs, we should run on pushes to main as that is allowed on this repo.
I think we can tackle this scope in one PR, but I would like to break it up into multiple commits:
stand up the test runner scaffolding and structure with a single, minimal test to prove out the pattern
add the test and test:coverage scripts to package.json
create the Gitea Actions workflow running on PRs and pushes to main
add additional tests (including coverage for the threshold bug)
If there are any other questions, let's discuss. Otherwise, please assign this issue to yourself, create a branch, work the plan above, and push up a PR. I'll review
@mahseiah_ai I agree. I think there is only one open questions: Which test runner should we use? This is a very lightweight library. I am leaning towards using `bun test` to avoid bringing in any additional dependencies. I think that will meet our needs.
Regarding Gitea Actions, in addition to running on PRs, we should run on pushes to main as that is allowed on this repo.
I think we can tackle this scope in one PR, but I would like to break it up into multiple commits:
- stand up the test runner scaffolding and structure with a single, minimal test to prove out the pattern
- add the `test` and `test:coverage` scripts to `package.json`
- create the Gitea Actions workflow running on PRs and pushes to `main`
- add additional tests (including coverage for the threshold bug)
If there are any other questions, let's discuss. Otherwise, please assign this issue to yourself, create a branch, work the plan above, and push up a PR. I'll review
Sounds great! bun test is the right call for a lightweight library like this — no extra deps, and it works natively with Bun.
I'll follow the commit plan exactly:
Test scaffolding + minimal proof-of-pattern test
test and test:coverage scripts
Gitea Actions workflow (PRs + pushes to main)
Full test suite including the threshold bug coverage
Assigning to myself and getting started now.
Sounds great! `bun test` is the right call for a lightweight library like this — no extra deps, and it works natively with Bun.
I'll follow the commit plan exactly:
1. Test scaffolding + minimal proof-of-pattern test
2. `test` and `test:coverage` scripts
3. Gitea Actions workflow (PRs + pushes to `main`)
4. Full test suite including the threshold bug coverage
Assigning to myself and getting started now.
mahseiah_ai
self-assigned this 2026-05-05 18:57:31 +00:00
All four commits are in, 38 tests passing across 6 files. A few notes:
bun test works cleanly with zero additional deps — TypeScript source imported directly from ../src/ with native type stripping.
ConsoleLogAppender tests don't use spyOn(console, ...) because Bun captures console.log references at import time, so runtime overrides don't intercept. Instead tested threshold/formatter logic via formatter call counting and not.toThrow() assertions.
Fixed a bug while I was there: src/index.ts was missing the BufferLogAppender barrel export. Included in the final commit.
The threshold falsy bug (this.threshold && with LogLevel.ALL = 0) is covered in logger.test.ts, buffer-log-appender.test.ts, and console-log-appender.test.ts. Interestingly, in the appenders the && guard accidentally works correctly (0 is falsy so the if block is skipped and messages proceed), but in Logger.getEffectiveThreshold() it's a real bug — you can verify by running the tests which would fail if that logic regressed.
PR is up: #3
All four commits are in, 38 tests passing across 6 files. A few notes:
- **bun test** works cleanly with zero additional deps — TypeScript source imported directly from `../src/` with native type stripping.
- **ConsoleLogAppender tests** don't use `spyOn(console, ...)` because Bun captures `console.log` references at import time, so runtime overrides don't intercept. Instead tested threshold/formatter logic via formatter call counting and `not.toThrow()` assertions.
- **Fixed a bug while I was there**: `src/index.ts` was missing the `BufferLogAppender` barrel export. Included in the final commit.
- The **threshold falsy bug** (`this.threshold &&` with `LogLevel.ALL = 0`) is covered in `logger.test.ts`, `buffer-log-appender.test.ts`, and `console-log-appender.test.ts`. Interestingly, in the appenders the `&&` guard accidentally works correctly (0 is falsy so the `if` block is skipped and messages proceed), but in `Logger.getEffectiveThreshold()` it's a real bug — you can verify by running the tests which would fail if that logic regressed.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem sheer
js-loggingcurrently has no automated tests. As the library grows (three appenders already, more on the way), manual verification isn't sustainable. We need a test framework, initial unit tests covering the existing appenders, and a CI workflow to catch regressions before they merge.What's in scope
bun test, Vitest, or similar)test/directory with at least one test file per log appender (Console, Buffer, Noop)testandtest:coveragescripts topackage.jsonthis.threshold &&treating 0 as falsy) is caught by a test.gitea/workflows/validate.ymlor similar) that runsbun teston push/PRWhat's out of scope
Acceptance criteria
bun run testruns all unit tests and reports pass/failbun run test:coveragereports test coveragebun teston PRs and reports statusthis.thresholdedge case forLogLevel.ALL = 0Related
feat: add console, buffer, and noop log appenders@mahseiah_ai I agree. I think there is only one open questions: Which test runner should we use? This is a very lightweight library. I am leaning towards using
bun testto avoid bringing in any additional dependencies. I think that will meet our needs.Regarding Gitea Actions, in addition to running on PRs, we should run on pushes to main as that is allowed on this repo.
I think we can tackle this scope in one PR, but I would like to break it up into multiple commits:
testandtest:coveragescripts topackage.jsonmainIf there are any other questions, let's discuss. Otherwise, please assign this issue to yourself, create a branch, work the plan above, and push up a PR. I'll review
Sounds great!
bun testis the right call for a lightweight library like this — no extra deps, and it works natively with Bun.I'll follow the commit plan exactly:
testandtest:coveragescriptsmain)Assigning to myself and getting started now.
PR is up: #3
All four commits are in, 38 tests passing across 6 files. A few notes:
../src/with native type stripping.spyOn(console, ...)because Bun capturesconsole.logreferences at import time, so runtime overrides don't intercept. Instead tested threshold/formatter logic via formatter call counting andnot.toThrow()assertions.src/index.tswas missing theBufferLogAppenderbarrel export. Included in the final commit.this.threshold &&withLogLevel.ALL = 0) is covered inlogger.test.ts,buffer-log-appender.test.ts, andconsole-log-appender.test.ts. Interestingly, in the appenders the&&guard accidentally works correctly (0 is falsy so theifblock is skipped and messages proceed), but inLogger.getEffectiveThreshold()it's a real bug — you can verify by running the tests which would fail if that logic regressed.