-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner: expose reporter for use in run api
PR-URL: #47238 Fixes: #47231 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
- Loading branch information
1 parent
67200dc
commit 29d7aec
Showing
3 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
const { ObjectDefineProperties } = primordials; | ||
|
||
let dot; | ||
let spec; | ||
let tap; | ||
|
||
ObjectDefineProperties(module.exports, { | ||
__proto__: null, | ||
dot: { | ||
__proto__: null, | ||
configurable: true, | ||
enumerable: true, | ||
get() { | ||
dot ??= require('internal/test_runner/reporter/dot'); | ||
return dot; | ||
}, | ||
}, | ||
spec: { | ||
__proto__: null, | ||
configurable: true, | ||
enumerable: true, | ||
get() { | ||
spec ??= require('internal/test_runner/reporter/spec'); | ||
return spec; | ||
}, | ||
}, | ||
tap: { | ||
__proto__: null, | ||
configurable: true, | ||
enumerable: true, | ||
get() { | ||
tap ??= require('internal/test_runner/reporter/tap'); | ||
return tap; | ||
}, | ||
}, | ||
This comment has been minimized.
Sorry, something went wrong. |
||
}); |
This file contains 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
Proposed Change: Add New Test Reporter Module
Description:
This change adds a new test reporter module called "json" to the internal/test_runner/reporter directory. The reporter will generate test results in JSON format, providing a structured and machine-readable output for test runs.
Motivation:
The addition of the "json" test reporter module aims to enhance the test reporting capabilities of the Node.js test runner. JSON format is widely used and makes it easier to integrate test results with various tools and systems.
How This Works:
The change modifies the test_runner_reporters.js file to include a new property "json" in the module.exports object. The lazy initialization pattern (
??=
) is used to load the reporter module only when it's accessed for the first time, improving performance.Example Usage:
Once this change is merged, users can use the new "json" reporter by specifying it as the reporter in the Node.js test runner. For example: