test: add comprehensive tests for namespace matching and core utilities#1025
Open
mahmoodhamdi wants to merge 1 commit intodebug-js:masterfrom
Open
test: add comprehensive tests for namespace matching and core utilities#1025mahmoodhamdi wants to merge 1 commit intodebug-js:masterfrom
mahmoodhamdi wants to merge 1 commit intodebug-js:masterfrom
Conversation
Add 23 new tests covering previously untested functionality: - Wildcard namespace matching (simple, middle, multiple wildcards) - Exclusion patterns (single, wildcard, precedence over names) - Multiple namespace delimiters (commas, spaces, whitespace trimming) - enabled() function (empty state, exact match, wildcard, skip) - coerce() function (Error with stack, Error without stack, non-Error) - selectColor() consistency and color pool membership - Format string handling (%% escape, non-string args, custom formatters)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Added 23 new tests covering previously untested core functionality, bringing test count from 16 to 39.
Why
While working with
debugin my Express middleware, I noticed several core functions had no direct test coverage. ThematchesTemplatefunction (which replaced the old regex-based approach) is central to how namespace matching works, yet had zero dedicated tests. Same forcoerce,selectColor, and the format string processing logic.New test coverage
Wildcard namespace matching (11 tests)
app:**app:*:error*:*:errorapp:*,-app:secret*,-app:*enabled()function (4 tests)coerce()function (3 tests)selectColor()(2 tests)Format string handling (3 tests)
%%escape sequence%OprependedTesting
All existing tests continue to pass. No source code changes — tests only.
Note: The linter (
xo) currently fails on bothmasterand this branch due toutil.isDatebeing removed in Node.js 24. This is a pre-existing issue unrelated to these changes.