Skip to content

Commit

Permalink
💥 update jasmine types
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Apr 10, 2021
1 parent eca3f45 commit 000ead1
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 8 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
# 7.0.0

## Bugfix

* 'SpecReporter' is not assignable to type 'Reporter | CustomReporter' [#588](https://github.com/bcaudan/jasmine-spec-reporter/pull/588)

## Breaking change

Update signature of `CustomReporterResult` to fix collision with new jasmine properties

**Before:**
```ts
export interface CustomReporterResult extends jasmine.CustomReporterResult {
duration?: string;
}
```

**Now:**
```ts
export interface CustomReporterResult extends jasmine.CustomReporterResult {
_jsr?: {
formattedDuration?: string;
};
}
```

# 6.0.0

## Feature
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"colors": "1.4.0"
},
"devDependencies": {
"@types/jasmine": "3.6.2",
"@types/jasmine": "3.6.9",
"@types/node": "14.14.37",
"codecov": "3.8.1",
"diff": "5.0.0",
Expand Down
4 changes: 3 additions & 1 deletion src/display/execution-display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class ExecutionDisplay {
let isDisplayed = false;
processors.forEach((processor: DisplayProcessor) => {
const log = "foo";
const result = processor.displaySpecStarted({id: "bar", description: "bar", fullName: "bar"}, log);
const result = processor.displaySpecStarted({id: "bar", description: "bar", fullName: "bar", duration: null, properties: null}, log);
isDisplayed = isDisplayed || result !== log;
});
return isDisplayed;
Expand Down Expand Up @@ -120,6 +120,8 @@ export class ExecutionDisplay {
description: name,
fullName: name,
id: name,
properties: null,
duration: null
};
this.suiteHierarchy.push(topLevelSuite);
this.suiteHierarchyDisplayed.push(topLevelSuite);
Expand Down
4 changes: 3 additions & 1 deletion src/execution-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export class ExecutionMetrics {
}

public stopSpec(result: CustomReporterResult): void {
result.duration = this.formatDuration((new Date()).getTime() - this.specStartTime);
result._jsr = {
formattedDuration: this.formatDuration((new Date()).getTime() - this.specStartTime)
};
}

private formatDuration(durationInMs: number): string {
Expand Down
2 changes: 1 addition & 1 deletion src/processors/spec-durations-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {CustomReporterResult} from "../spec-reporter";

export class SpecDurationsProcessor extends DisplayProcessor {
private static displayDuration(spec: CustomReporterResult, log: string): string {
return `${log} (${spec.duration})`;
return `${log} (${spec._jsr && spec._jsr.formattedDuration})`;
}

public displaySuccessfulSpec(spec: CustomReporterResult, log: string): string {
Expand Down
6 changes: 5 additions & 1 deletion src/spec-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import SuiteInfo = jasmine.SuiteInfo;
import RunDetails = jasmine.RunDetails;

export interface CustomReporterResult extends jasmine.CustomReporterResult {
duration?: string;
_jsr?: {
formattedDuration?: string;
};
}

export interface ExecutedSpecs {
Expand Down Expand Up @@ -136,6 +138,8 @@ export class SpecReporter implements CustomReporter {
}),
fullName: "Non-spec failure",
id: "Non-spec failure",
duration: null,
properties: null
};
}

Expand Down

0 comments on commit 000ead1

Please sign in to comment.