Gathering detailed insights and metrics for @japa/base-reporter
Gathering detailed insights and metrics for @japa/base-reporter
Gathering detailed insights and metrics for @japa/base-reporter
Gathering detailed insights and metrics for @japa/base-reporter
Base reporter to create customized tests reporter for Japa
npm install @japa/base-reporter
Typescript
Module System
Node Version
NPM Version
80.2
Supply Chain
96.7
Quality
77.1
Maintenance
100
Vulnerability
98.9
License
Upgrade to latest @japa/core
Updated on Jun 23, 2023
Preparing for Japa v3
Updated on Jun 23, 2023
Remove peer dependency from @japa/core
Updated on Mar 03, 2023
Update dependencies
Updated on Feb 07, 2023
Print aggregates in a compact view
Updated on Oct 17, 2022
Fix hooks error reporting
Updated on Sep 18, 2022
TypeScript (99.19%)
Shell (0.81%)
Total Downloads
1,111,389
Last Day
1,832
Last Week
7,641
Last Month
28,969
Last Year
406,911
MIT License
1 Stars
21 Commits
2 Watchers
3 Branches
3 Contributors
Updated on Sep 25, 2023
Minified
Minified + Gzipped
Latest Version
1.1.2
Package Id
@japa/base-reporter@1.1.2
Unpacked Size
14.32 kB
Size
4.74 kB
File Count
9
NPM Version
9.5.1
Node Version
19.6.1
Published on
Mar 03, 2023
Cumulative downloads
Total Downloads
Last Day
42.1%
1,832
Compared to previous day
Last Week
30.3%
7,641
Compared to previous week
Last Month
1.3%
28,969
Compared to previous month
Last Year
-18.2%
406,911
Compared to previous year
3
Japa Base Reporter
Base reporter to create customized testing reporters for Japa
The Base reporter abstracts the repetitive parts of creating a tests reporters.
Install the package from npm registry as follows:
1npm i @japa/base-reporter 2 3# Yarn lovers 4yarn add @japa/base-reporter
1import { BaseReporter } from '@japa/base-reporter' 2 3class MyReporter extends BaseReporter {} 4 5export const reporterFn = (myReporterOptions = {}) => { 6 const myReporter = new MyReporter(myReporterOptions) 7 return myReporter.boot.bind(reporter) 8}
The Base reporter invokes following methods as it receives the events from the runner. You can implement these methods to display the tests progress.
1import type { 2 TestEndNode, 3 SuiteEndNode, 4 GroupEndNode, 5 TestStartNode, 6 RunnerEndNode, 7 GroupStartNode, 8 SuiteStartNode, 9 RunnerStartNode, 10} from '@japa/core' 11 12class SpecReporter extends BaseReporter { 13 protected onTestStart(payload: TestStartNode) { 14 console.log('test started') 15 } 16 protected onTestEnd(payload: TestEndNode) { 17 console.log('test endeded') 18 } 19 20 protected onGroupStart(payload: GroupStartNode) { 21 console.log('group started') 22 } 23 protected onGroupEnd(payload: GroupEndNode) { 24 console.log('group ended') 25 } 26 27 protected onSuiteStart(payload: SuiteStartNode) { 28 console.log('suite started') 29 } 30 protected onSuiteEnd(payload: SuiteEndNode) { 31 console.log('suite ended') 32 } 33 34 protected async start(payload: RunnerStartNode) { 35 console.log('test runner started. You can run async operations here') 36 } 37 protected async end(payload: RunnerEndNode) { 38 console.log('test runner ended. You can run async operations here') 39 } 40}
The following properties are available on the BaseReporter. These properties are available only after the boot method is called.
Reference to underlying tests runner instance.
1this.runner
Reference to the file name for which tests are getting executed. The filename is only available inside the test or group handlers.
1this.currentFileName
Reference to the suite name for which tests are getting executed. The suite name is only available after the onSuiteStart
handler call.
1this.currentSuiteName
Uncaught exceptions collected while tests are running. We rely on process.on('uncaughtException')
event to collect uncaught exceptions and display them with their stack trace at the end.
After all the tests have been finished, you can call the printSummary
method to print a detailed summary of all tests alongside pretty diffs and pretty error stack trace.
You should call the printSummary
method from the end
handler.
1class SpecReporter extends BaseReporter { 2 protected async end() { 3 const summary = await this.runner.getSummary() 4 await this.printSummary(summary) 5 } 6}
No vulnerabilities found.
No security vulnerabilities found.