diff --git a/CHANGELOG.md b/CHANGELOG.md index c39f0eb3..903e6f81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +# 4.0.0 + +* Use string primitive instead of String wrapper object [#134](https://github.com/bcaudan/jasmine-spec-reporter/issues/134), [#137](https://github.com/bcaudan/jasmine-spec-reporter/issues/137) + +## Breaking change + +It only impacts TypeScript integrations, `DisplayProcessor` methods signature now use `string` instead of `String`. + +Before: + + displaySuite(suite: CustomReporterResult, log: String): String; + +Now: + + displaySuite(suite: CustomReporterResult, log: string): string; + # 3.3.0 * Add low-level print configuration option [#129](https://github.com/bcaudan/jasmine-spec-reporter/issues/129), [#130](https://github.com/bcaudan/jasmine-spec-reporter/issues/130) diff --git a/examples/typescript/README.md b/examples/typescript/README.md index f0cb302c..a32dc0eb 100644 --- a/examples/typescript/README.md +++ b/examples/typescript/README.md @@ -10,7 +10,7 @@ const Jasmine = require("jasmine"); import SuiteInfo = jasmine.SuiteInfo; class CustomProcessor extends DisplayProcessor { - public displayJasmineStarted(info: SuiteInfo, log: String): String { + public displayJasmineStarted(info: SuiteInfo, log: string): string { return `TypeScript ${log}`; } } diff --git a/examples/typescript/spec/helpers/jasmine-runner.ts b/examples/typescript/spec/helpers/jasmine-runner.ts index 51680df9..6b498de0 100644 --- a/examples/typescript/spec/helpers/jasmine-runner.ts +++ b/examples/typescript/spec/helpers/jasmine-runner.ts @@ -4,7 +4,7 @@ const Jasmine = require("jasmine"); import SuiteInfo = jasmine.SuiteInfo; class CustomProcessor extends DisplayProcessor { - public displayJasmineStarted(info: SuiteInfo, log: String): String { + public displayJasmineStarted(info: SuiteInfo, log: string): string { return `TypeScript ${log}`; } } diff --git a/spec/helpers/test-processor.ts b/spec/helpers/test-processor.ts index f136956c..b88397cb 100644 --- a/spec/helpers/test-processor.ts +++ b/spec/helpers/test-processor.ts @@ -9,35 +9,35 @@ export class TestProcessor extends DisplayProcessor { this.test = configuration.customOptions.test; } - public displayJasmineStarted(info: any, log: String): String { + public displayJasmineStarted(info: any, log: string): string { return log + this.test; } - public displaySuite(suite: any, log: String): String { + public displaySuite(suite: any, log: string): string { return log + this.test; } - public displaySpecStarted(spec: any, log: String): String { + public displaySpecStarted(spec: any, log: string): string { return spec.description + this.test; } - public displaySuccessfulSpec(spec: any, log: String): String { + public displaySuccessfulSpec(spec: any, log: string): string { return log + this.test; } - public displayFailedSpec(spec: any, log: String): String { + public displayFailedSpec(spec: any, log: string): string { return log + this.test; } - public displaySpecErrorMessages(spec: any, log: String): String { + public displaySpecErrorMessages(spec: any, log: string): string { return log + this.test; } - public displaySummaryErrorMessages(spec: any, log: String): String { + public displaySummaryErrorMessages(spec: any, log: string): string { return log + this.test; } - public displayPendingSpec(spec: any, log: String): String { + public displayPendingSpec(spec: any, log: string): string { return log + this.test; } } diff --git a/src/configuration.ts b/src/configuration.ts index 8cecb824..aec40ff3 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -114,7 +114,7 @@ export class Configuration { /** * Customize stacktrace filtering */ - filter?(stacktrace: String): String; + filter?(stacktrace: string): string; }; /** * list of display processor to customize output @@ -130,5 +130,5 @@ export class Configuration { * Use process.stdout.write(log + '\n'); to avoid output to * devtools console while still reporting to command line. */ - public print?: (log: String) => void; + public print?: (log: string) => void; } diff --git a/src/display-processor.ts b/src/display-processor.ts index 726292c8..332263b3 100644 --- a/src/display-processor.ts +++ b/src/display-processor.ts @@ -9,35 +9,35 @@ export class DisplayProcessor { this.configuration = configuration; } - public displayJasmineStarted(info: SuiteInfo, log: String): String { + public displayJasmineStarted(info: SuiteInfo, log: string): string { return log; } - public displaySuite(suite: CustomReporterResult, log: String): String { + public displaySuite(suite: CustomReporterResult, log: string): string { return log; } - public displaySpecStarted(spec: CustomReporterResult, log: String): String { + public displaySpecStarted(spec: CustomReporterResult, log: string): string { return log; } - public displaySuccessfulSpec(spec: CustomReporterResult, log: String): String { + public displaySuccessfulSpec(spec: CustomReporterResult, log: string): string { return log; } - public displayFailedSpec(spec: CustomReporterResult, log: String): String { + public displayFailedSpec(spec: CustomReporterResult, log: string): string { return log; } - public displaySpecErrorMessages(spec: CustomReporterResult, log: String): String { + public displaySpecErrorMessages(spec: CustomReporterResult, log: string): string { return log; } - public displaySummaryErrorMessages(spec: CustomReporterResult, log: String): String { + public displaySummaryErrorMessages(spec: CustomReporterResult, log: string): string { return log; } - public displayPendingSpec(spec: CustomReporterResult, log: String): String { + public displayPendingSpec(spec: CustomReporterResult, log: string): string { return log; } } diff --git a/src/display/execution-display.ts b/src/display/execution-display.ts index 2eb803c7..c1d32c70 100644 --- a/src/display/execution-display.ts +++ b/src/display/execution-display.ts @@ -28,7 +28,7 @@ export class ExecutionDisplay { } public jasmineStarted(suiteInfo: SuiteInfo): void { - this.logger.process(suiteInfo, (displayProcessor: DisplayProcessor, object: SuiteInfo, log: String) => { + this.logger.process(suiteInfo, (displayProcessor: DisplayProcessor, object: SuiteInfo, log: string) => { return displayProcessor.displayJasmineStarted(object, log); }); } @@ -38,7 +38,7 @@ export class ExecutionDisplay { this.ensureSuiteDisplayed(); this.logger.process( result, - (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: String) => { + (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: string) => { return displayProcessor.displaySpecStarted(object, log); } ); @@ -51,7 +51,7 @@ export class ExecutionDisplay { this.ensureSuiteDisplayed(); this.logger.process( result, - (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: String) => { + (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: string) => { return displayProcessor.displaySuccessfulSpec(object, log); } ); @@ -64,7 +64,7 @@ export class ExecutionDisplay { this.ensureSuiteDisplayed(); this.logger.process( result, - (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: String) => { + (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: string) => { return displayProcessor.displayFailedSpec(object, log); } ); @@ -72,7 +72,7 @@ export class ExecutionDisplay { this.logger.increaseIndent(); this.logger.process( result, - (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: String) => { + (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: string) => { return displayProcessor.displaySpecErrorMessages(object, log); } ); @@ -87,7 +87,7 @@ export class ExecutionDisplay { this.ensureSuiteDisplayed(); this.logger.process( result, - (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: String) => { + (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: string) => { return displayProcessor.displayPendingSpec(object, log); } ); @@ -129,7 +129,7 @@ export class ExecutionDisplay { private displaySuite(suite: CustomReporterResult): void { this.logger.newLine(); this.computeSuiteIndent(); - this.logger.process(suite, (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: String) => { + this.logger.process(suite, (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: string) => { return displayProcessor.displaySuite(object, log); }); this.logger.increaseIndent(); diff --git a/src/display/logger.ts b/src/display/logger.ts index e5b25bef..8d09c79c 100644 --- a/src/display/logger.ts +++ b/src/display/logger.ts @@ -2,7 +2,7 @@ import {DisplayProcessor} from "../display-processor"; import {CustomReporterResult} from "../spec-reporter"; import SuiteInfo = jasmine.SuiteInfo; -export type ProcessFunction = (displayProcessor: DisplayProcessor, object: ProcessObject, log: String) => String; +export type ProcessFunction = (displayProcessor: DisplayProcessor, object: ProcessObject, log: string) => string; export type ProcessObject = SuiteInfo | CustomReporterResult; export class Logger { @@ -10,18 +10,18 @@ export class Logger { private currentIndent = ""; private lastWasNewLine = false; - constructor(private displayProcessors: DisplayProcessor[], private print: (line: String) => void) { + constructor(private displayProcessors: DisplayProcessor[], private print: (line: string) => void) { } - public log(stuff: String): void { - stuff.split("\n").forEach((line: String) => { + public log(stuff: string): void { + stuff.split("\n").forEach((line: string) => { this.print(line !== "" ? this.currentIndent + line : line); }); this.lastWasNewLine = false; } public process(object: ProcessObject, processFunction: ProcessFunction): void { - let log: String = ""; + let log = ""; this.displayProcessors.forEach((displayProcessor: DisplayProcessor) => { log = processFunction(displayProcessor, object, log); }); diff --git a/src/display/summary-display.ts b/src/display/summary-display.ts index a6011c76..8d2fcf21 100644 --- a/src/display/summary-display.ts +++ b/src/display/summary-display.ts @@ -71,7 +71,7 @@ export class SummaryDisplay { this.logger.increaseIndent(); this.logger.process( spec, - (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: String) => { + (displayProcessor: DisplayProcessor, object: CustomReporterResult, log: string) => { return displayProcessor.displaySummaryErrorMessages(object, log); } ); diff --git a/src/processors/default-processor.ts b/src/processors/default-processor.ts index 167945e8..899b4f39 100644 --- a/src/processors/default-processor.ts +++ b/src/processors/default-processor.ts @@ -2,40 +2,40 @@ import {DisplayProcessor} from "../display-processor"; import {CustomReporterResult} from "../spec-reporter"; export class DefaultProcessor extends DisplayProcessor { - private static displaySpecDescription(spec: CustomReporterResult): String { + private static displaySpecDescription(spec: CustomReporterResult): string { return spec.description; } - public displayJasmineStarted(): String { + public displayJasmineStarted(): string { return "Spec started"; } - public displaySuite(suite: CustomReporterResult): String { + public displaySuite(suite: CustomReporterResult): string { return suite.description; } - public displaySuccessfulSpec(spec: CustomReporterResult): String { + public displaySuccessfulSpec(spec: CustomReporterResult): string { return DefaultProcessor.displaySpecDescription(spec); } - public displayFailedSpec(spec: CustomReporterResult): String { + public displayFailedSpec(spec: CustomReporterResult): string { return DefaultProcessor.displaySpecDescription(spec); } - public displaySpecErrorMessages(spec: CustomReporterResult): String { + public displaySpecErrorMessages(spec: CustomReporterResult): string { return this.displayErrorMessages(spec, this.configuration.spec.displayStacktrace); } - public displaySummaryErrorMessages(spec: CustomReporterResult): String { + public displaySummaryErrorMessages(spec: CustomReporterResult): string { return this.displayErrorMessages(spec, this.configuration.summary.displayStacktrace); } - public displayPendingSpec(spec: CustomReporterResult): String { + public displayPendingSpec(spec: CustomReporterResult): string { return DefaultProcessor.displaySpecDescription(spec); } - private displayErrorMessages(spec: CustomReporterResult, withStacktrace: boolean): String { - const logs: String[] = []; + private displayErrorMessages(spec: CustomReporterResult, withStacktrace: boolean): string { + const logs: string[] = []; for (const failedExpectation of spec.failedExpectations) { logs.push("- ".failed + failedExpectation.message.failed); if (withStacktrace && failedExpectation.stack) { diff --git a/src/processors/spec-colors-processor.ts b/src/processors/spec-colors-processor.ts index b82144a2..43c5dbf9 100644 --- a/src/processors/spec-colors-processor.ts +++ b/src/processors/spec-colors-processor.ts @@ -2,15 +2,15 @@ import {DisplayProcessor} from "../display-processor"; import {CustomReporterResult} from "../spec-reporter"; export class SpecColorsProcessor extends DisplayProcessor { - public displaySuccessfulSpec(spec: CustomReporterResult, log: String): String { + public displaySuccessfulSpec(spec: CustomReporterResult, log: string): string { return log.successful; } - public displayFailedSpec(spec: CustomReporterResult, log: String): String { + public displayFailedSpec(spec: CustomReporterResult, log: string): string { return log.failed; } - public displayPendingSpec(spec: CustomReporterResult, log: String): String { + public displayPendingSpec(spec: CustomReporterResult, log: string): string { return log.pending; } } diff --git a/src/processors/spec-durations-processor.ts b/src/processors/spec-durations-processor.ts index 2167c557..3d9b1555 100644 --- a/src/processors/spec-durations-processor.ts +++ b/src/processors/spec-durations-processor.ts @@ -2,15 +2,15 @@ import {DisplayProcessor} from "../display-processor"; import {CustomReporterResult} from "../spec-reporter"; export class SpecDurationsProcessor extends DisplayProcessor { - private static displayDuration(spec: CustomReporterResult, log: String): String { + private static displayDuration(spec: CustomReporterResult, log: string): string { return `${log} (${spec.duration})`; } - public displaySuccessfulSpec(spec: CustomReporterResult, log: String): String { + public displaySuccessfulSpec(spec: CustomReporterResult, log: string): string { return SpecDurationsProcessor.displayDuration(spec, log); } - public displayFailedSpec(spec: CustomReporterResult, log: String): String { + public displayFailedSpec(spec: CustomReporterResult, log: string): string { return SpecDurationsProcessor.displayDuration(spec, log); } } diff --git a/src/processors/spec-prefixes-processor.ts b/src/processors/spec-prefixes-processor.ts index 1d98b23d..ffd1ea71 100644 --- a/src/processors/spec-prefixes-processor.ts +++ b/src/processors/spec-prefixes-processor.ts @@ -2,15 +2,15 @@ import {DisplayProcessor} from "../display-processor"; import {CustomReporterResult} from "../spec-reporter"; export class SpecPrefixesProcessor extends DisplayProcessor { - public displaySuccessfulSpec(spec: CustomReporterResult, log: String): String { + public displaySuccessfulSpec(spec: CustomReporterResult, log: string): string { return this.configuration.prefixes.successful + log; } - public displayFailedSpec(spec: CustomReporterResult, log: String): String { + public displayFailedSpec(spec: CustomReporterResult, log: string): string { return this.configuration.prefixes.failed + log; } - public displayPendingSpec(spec: CustomReporterResult, log: String): String { + public displayPendingSpec(spec: CustomReporterResult, log: string): string { return this.configuration.prefixes.pending + log; } } diff --git a/src/processors/suite-numbering-processor.ts b/src/processors/suite-numbering-processor.ts index 6220eca0..741d5d55 100644 --- a/src/processors/suite-numbering-processor.ts +++ b/src/processors/suite-numbering-processor.ts @@ -2,28 +2,28 @@ import {DisplayProcessor} from "../display-processor"; import {CustomReporterResult} from "../spec-reporter"; interface SuiteHierarchyInfo { - name: String; + name: string; number: number; } export class SuiteNumberingProcessor extends DisplayProcessor { - private static getParentName(element: CustomReporterResult): String { + private static getParentName(element: CustomReporterResult): string { return element.fullName.replace(element.description, "").trim(); } private suiteHierarchy: SuiteHierarchyInfo[] = []; - public displaySuite(suite: CustomReporterResult, log: String): String { + public displaySuite(suite: CustomReporterResult, log: string): string { return `${this.computeNumber(suite)} ${log}`; } - private computeNumber(suite: CustomReporterResult): String { + private computeNumber(suite: CustomReporterResult): string { this.computeHierarchy(suite); return this.computeHierarchyNumber(); } private computeHierarchy(suite: CustomReporterResult): void { - const parentName: String = SuiteNumberingProcessor.getParentName(suite); + const parentName: string = SuiteNumberingProcessor.getParentName(suite); let i = 0; for (; i < this.suiteHierarchy.length; i++) { if (this.suiteHierarchy[i].name === parentName) { @@ -37,8 +37,8 @@ export class SuiteNumberingProcessor extends DisplayProcessor { } } - private computeHierarchyNumber(): String { - let hierarchyNumber: String = ""; + private computeHierarchyNumber(): string { + let hierarchyNumber = ""; for (const suite of this.suiteHierarchy) { hierarchyNumber += suite.number + "."; } diff --git a/tslint.json b/tslint.json index 4e74e9ed..68655025 100644 --- a/tslint.json +++ b/tslint.json @@ -53,7 +53,6 @@ "no-unnecessary-qualifier": true, "strict-type-predicates": true, "align": [true, "parameters", "statements", "arguments"], - "ban-types": [true, ["Object", "Use {} instead."]], "no-inferrable-types": true, "eofline": true, "curly": true,