test: cover Node-specific paths and namespace matching - #1057
Open
appsir2016-lab wants to merge 1 commit into
Open
appsir2016-lab wants to merge 1 commit into
appsir2016-lab wants to merge 1 commit into
Conversation
Adds 31 tests, no source changes. Node-side statement coverage (src/node.js, src/common.js, src/index.js) goes from 77.7% to 99.7%; src/node.js and src/index.js reach 100%. Covered: the extended colour palette when supports-color reports level 2 or more, DEBUG_* environment parsing and value coercion, useColors TTY fallback, colour and date prefixes in formatArgs, the %o and %O formatters, save/load of process.env.DEBUG, per-instance inspectOpts, the deprecated destroy() no-op, the Electron/browser detection in the entry file, escaped %% sequences, wildcard backtracking and trailing wildcards in namespace matching, skip lists, whitespace-separated namespaces, and Error coercion with and without a stack. Measured with: npx c8 --all --src src --exclude 'test*.js' npm run test:node Signed-off-by: P & A Dawn works <appsir2016@gmail.com>
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.
Adds 31 tests to the two existing test files. No source changes, no new dependencies, and the
test:nodescript is unchanged. The tests added totest.jsuse no Node APIs; the karma suite was run locally with headless Chrome and passes (22 tests, 8 of them new).Statement coverage of
npm run test:node, measured withnpx c8 --all --src src --exclude 'test*.js':What is covered now:
supports-colorreports level 2+, the basic palette otherwise, and the older module shape withoutstderr. Four tests interceptModule._loadforsupports-colorso the branch runs regardless of whether the optional module is installed on the machine.DEBUG_*environment parsing and value coercion.useColors()withinspectOpts.colorsset and with the TTY fallback.formatArgs: colour prefix, the 256-colour escape, multi-line prefixes, the date prefix andhideDate.%oand%Oformatters, including per-instanceinspectOptsand colours passed toutil.inspect.save,load,log, per-instanceinspectOptsfrominit, and the deprecateddestroy()no-op.src/index.js.%%, a non-string first argument, Error coercion with and without a stack, wildcard backtracking and trailing wildcards, skip lists, and whitespace-separated namespaces.Two things noticed while running the suite and left alone here:
xo0.23 crashes on current Node (util.isDate is not a function, fromcore-assertviaeslint-plugin-ava), sonpm run lintneeds Node 22 or lower, or a newerxo. I ran the linter on the two test files with a local shim restoring the removedutil.is*helpers for the linter process only; both files are clean.destroy()insrc/common.jsis unreachable in the Node build becausesrc/node.jssupplies its own, so its two lines stay uncovered.Checks:
npm run test:nodepasses with 47 tests on Node 26, andnpm run test:browserpasses with 22 tests in headless Chrome 152.