New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@japa/base-reporter

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@japa/base-reporter - npm Package Compare versions

Comparing version 2.0.0-0 to 2.0.0-1

9

build/src/base_reporter.d.ts

@@ -0,5 +1,8 @@

import { cliui } from '@poppinss/cliui';
import type { BaseReporterOptions } from './types.js';
import type { Emitter, Runner, TestEndNode, SuiteEndNode, GroupEndNode, TestStartNode, RunnerEndNode, GroupStartNode, SuiteStartNode, RunnerStartNode } from '@japa/core';
import { Emitter, Runner } from '@japa/core';
import type { TestEndNode, SuiteEndNode, GroupEndNode, TestStartNode, RunnerEndNode, GroupStartNode, SuiteStartNode, RunnerStartNode } from '@japa/core/types';
export declare abstract class BaseReporter {
#private;
ui: ReturnType<typeof cliui>;
runner: Runner<any>;

@@ -12,3 +15,5 @@ currentFileName?: string;

}[];
constructor(options?: Partial<BaseReporterOptions>);
constructor(options?: Partial<BaseReporterOptions>, ui?: ReturnType<typeof cliui>);
get logger(): import("@poppinss/cliui").Logger;
get colors(): import("@poppinss/colors/types").Colors;
protected onTestStart(_: TestStartNode): void;

@@ -15,0 +20,0 @@ protected onTestEnd(_: TestEndNode): void;

@@ -5,4 +5,4 @@ import ms from 'ms';

export class BaseReporter {
ui;
#options;
#ui = cliui();
runner;

@@ -12,9 +12,14 @@ currentFileName;

uncaughtExceptions = [];
constructor(options = {}) {
this.#options = {
stackLinesCount: options.stackLinesCount || 5,
};
constructor(options = {}, ui = cliui()) {
this.ui = ui;
this.#options = { stackLinesCount: options.stackLinesCount || 5 };
}
get logger() {
return this.ui.logger;
}
get colors() {
return this.ui.colors;
}
#printKeyValuePair(key, value, whitespaceLength) {
console.log(`${this.#ui.colors.dim(`${key.padEnd(whitespaceLength + 2)} : `)}${value}`);
this.logger.log(`${this.colors.dim(`${key.padEnd(whitespaceLength + 2)} : `)}${value}`);
}

@@ -31,23 +36,23 @@ onTestStart(_) { }

const [tests, time] = [[], []];
time.push(this.#ui.colors.dim(ms(summary.duration)));
time.push(this.colors.dim(ms(summary.duration)));
if (summary.aggregates.passed) {
tests.push(this.#ui.colors.green(`${summary.aggregates.passed} passed`));
tests.push(this.colors.green(`${summary.aggregates.passed} passed`));
}
if (summary.aggregates.failed) {
tests.push(this.#ui.colors.red(`${summary.aggregates.failed} failed`));
tests.push(this.colors.red(`${summary.aggregates.failed} failed`));
}
if (summary.aggregates.todo) {
tests.push(this.#ui.colors.cyan(`${summary.aggregates.todo} todo`));
tests.push(this.colors.cyan(`${summary.aggregates.todo} todo`));
}
if (summary.aggregates.skipped) {
tests.push(this.#ui.colors.yellow(`${summary.aggregates.skipped} skipped`));
tests.push(this.colors.yellow(`${summary.aggregates.skipped} skipped`));
}
if (summary.aggregates.regression) {
tests.push(this.#ui.colors.magenta(`${summary.aggregates.regression} regression`));
tests.push(this.colors.magenta(`${summary.aggregates.regression} regression`));
}
const keysPadding = summary.aggregates.uncaughtExceptions ? 19 : 5;
this.#printKeyValuePair('Tests', `${tests.join(', ')} ${this.#ui.colors.dim(`(${summary.aggregates.total})`)}`, keysPadding);
this.#printKeyValuePair('Tests', `${tests.join(', ')} ${this.colors.dim(`(${summary.aggregates.total})`)}`, keysPadding);
this.#printKeyValuePair('Time', time.join(''), keysPadding);
if (summary.aggregates.uncaughtExceptions) {
this.#printKeyValuePair('Uncaught exceptions', this.#ui.colors.red(String(summary.aggregates.uncaughtExceptions)), keysPadding);
this.#printKeyValuePair('Uncaught exceptions', this.colors.red(String(summary.aggregates.uncaughtExceptions)), keysPadding);
}

@@ -57,4 +62,4 @@ }

if (summary.failureTree.length || this.uncaughtExceptions.length) {
console.log('');
console.log('');
this.logger.log('');
this.logger.log('');
}

@@ -81,14 +86,14 @@ const errorPrinter = new ErrorsPrinter({

async printSummary(summary) {
console.log('');
this.logger.log('');
if (summary.aggregates.total === 0 && !summary.hasError) {
console.log(this.#ui.colors.bgYellow().black(' NO TESTS EXECUTED '));
this.logger.log(this.colors.bgYellow().black(' NO TESTS EXECUTED '));
return;
}
if (summary.hasError) {
console.log(this.#ui.colors.bgRed().black(' FAILED '));
this.logger.log(this.colors.bgRed().black(' FAILED '));
}
else {
console.log(this.#ui.colors.bgGreen().black(' PASSED '));
this.logger.log(this.colors.bgGreen().black(' PASSED '));
}
console.log('');
this.logger.log('');
this.#printAggregates(summary);

@@ -95,0 +100,0 @@ await this.#printErrors(summary);

{
"name": "@japa/base-reporter",
"description": "Base reporter to create customized testing reporters for Japa",
"version": "2.0.0-0",
"version": "2.0.0-1",
"engines": {

@@ -43,3 +43,3 @@ "node": ">=18.16.0"

"@japa/assert": "^1.4.1",
"@japa/core": "^7.3.3",
"@japa/core": "^8.0.0-0",
"@japa/run-failed-tests": "^1.1.1",

@@ -46,0 +46,0 @@ "@japa/runner": "^2.5.1",

@@ -14,5 +14,4 @@ /*

import type { BaseReporterOptions } from './types.js'
import { Emitter, Runner } from '@japa/core'
import type {
Emitter,
Runner,
TestEndNode,

@@ -26,3 +25,3 @@ SuiteEndNode,

RunnerStartNode,
} from '@japa/core'
} from '@japa/core/types'

@@ -34,3 +33,2 @@ /**

#options: BaseReporterOptions
#ui = cliui()

@@ -59,13 +57,28 @@ /**

constructor(options: Partial<BaseReporterOptions> = {}) {
this.#options = {
stackLinesCount: options.stackLinesCount || 5,
}
constructor(
options: Partial<BaseReporterOptions> = {},
public ui: ReturnType<typeof cliui> = cliui()
) {
this.#options = { stackLinesCount: options.stackLinesCount || 5 }
}
/**
* Logger to log messages
*/
get logger() {
return this.ui.logger
}
/**
* Add colors to console messages
*/
get colors() {
return this.ui.colors
}
/**
* Print the aggregate count
*/
#printKeyValuePair(key: string, value: string, whitespaceLength: number) {
console.log(`${this.#ui.colors.dim(`${key.padEnd(whitespaceLength + 2)} : `)}${value}`)
this.logger.log(`${this.colors.dim(`${key.padEnd(whitespaceLength + 2)} : `)}${value}`)
}

@@ -97,3 +110,3 @@

*/
time.push(this.#ui.colors.dim(ms(summary.duration)))
time.push(this.colors.dim(ms(summary.duration)))

@@ -104,15 +117,15 @@ /**

if (summary.aggregates.passed) {
tests.push(this.#ui.colors.green(`${summary.aggregates.passed} passed`))
tests.push(this.colors.green(`${summary.aggregates.passed} passed`))
}
if (summary.aggregates.failed) {
tests.push(this.#ui.colors.red(`${summary.aggregates.failed} failed`))
tests.push(this.colors.red(`${summary.aggregates.failed} failed`))
}
if (summary.aggregates.todo) {
tests.push(this.#ui.colors.cyan(`${summary.aggregates.todo} todo`))
tests.push(this.colors.cyan(`${summary.aggregates.todo} todo`))
}
if (summary.aggregates.skipped) {
tests.push(this.#ui.colors.yellow(`${summary.aggregates.skipped} skipped`))
tests.push(this.colors.yellow(`${summary.aggregates.skipped} skipped`))
}
if (summary.aggregates.regression) {
tests.push(this.#ui.colors.magenta(`${summary.aggregates.regression} regression`))
tests.push(this.colors.magenta(`${summary.aggregates.regression} regression`))
}

@@ -123,3 +136,3 @@

'Tests',
`${tests.join(', ')} ${this.#ui.colors.dim(`(${summary.aggregates.total})`)}`,
`${tests.join(', ')} ${this.colors.dim(`(${summary.aggregates.total})`)}`,
keysPadding

@@ -132,3 +145,3 @@ )

'Uncaught exceptions',
this.#ui.colors.red(String(summary.aggregates.uncaughtExceptions)),
this.colors.red(String(summary.aggregates.uncaughtExceptions)),
keysPadding

@@ -144,4 +157,4 @@ )

if (summary.failureTree.length || this.uncaughtExceptions.length) {
console.log('')
console.log('')
this.logger.log('')
this.logger.log('')
}

@@ -181,6 +194,6 @@

async printSummary(summary: ReturnType<Runner<any>['getSummary']>) {
console.log('')
this.logger.log('')
if (summary.aggregates.total === 0 && !summary.hasError) {
console.log(this.#ui.colors.bgYellow().black(' NO TESTS EXECUTED '))
this.logger.log(this.colors.bgYellow().black(' NO TESTS EXECUTED '))
return

@@ -190,7 +203,7 @@ }

if (summary.hasError) {
console.log(this.#ui.colors.bgRed().black(' FAILED '))
this.logger.log(this.colors.bgRed().black(' FAILED '))
} else {
console.log(this.#ui.colors.bgGreen().black(' PASSED '))
this.logger.log(this.colors.bgGreen().black(' PASSED '))
}
console.log('')
this.logger.log('')

@@ -197,0 +210,0 @@ this.#printAggregates(summary)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc