Skip to content

Commit

Permalink
fix: review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolai Markov committed Jun 8, 2023
1 parent 3514704 commit 31ceb6f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/browser/commands/assert-view/errors/assert-view-error.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export class AssertViewError extends Error {
constructor(message: string) {
constructor(public message: string = "image comparison failed") {
super();

this.name = this.constructor.name;
this.message = message || "image comparison failed";
}
}
6 changes: 1 addition & 5 deletions src/browser/commands/assert-view/errors/base-state-error.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { ImageInfo } from "../../../../types";

export class BaseStateError extends Error {
constructor(
public stateName: string,
public currImg: ImageInfo = {} as ImageInfo,
public refImg: ImageInfo = {} as ImageInfo,
) {
constructor(public stateName: string, public currImg: ImageInfo, public refImg: ImageInfo) {
super();

this.name = this.constructor.name;
Expand Down
7 changes: 3 additions & 4 deletions src/runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type RegisterWorkers<T extends ReadonlyArray<string>> = EventEmitter & MapOfMeth
export class MainRunner extends Runner {
protected _config: Config;
protected _interceptors: Interceptor[];
protected _browserPool: pool.BrowserPool;
protected _browserPool: pool.BrowserPool | null;
protected _activeBrowserRunners: Map<string, BrowserRunner>;
protected _running: PromiseGroup;
protected _runned: boolean;
Expand All @@ -51,8 +51,7 @@ export class MainRunner extends Runner {

this._config = config;
this._interceptors = interceptors;
// TODO: handle null safely
this._browserPool = null as unknown as pool.BrowserPool;
this._browserPool = null;

this._activeBrowserRunners = new Map();

Expand Down Expand Up @@ -174,7 +173,7 @@ export class MainRunner extends Runner {

cancel(): void {
this._cancelled = true;
this._browserPool.cancel();
this._browserPool?.cancel();

this._activeBrowserRunners.forEach(runner => runner.cancel());
}
Expand Down
6 changes: 5 additions & 1 deletion test/src/browser/commands/assert-view/assert-view-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ const { NoRefImageError } = require("src/browser/commands/assert-view/errors/no-
describe("AssertViewResults", () => {
describe("fromRawObject", () => {
it("should create an instance form a raw object", () => {
const obj = [{ name: ImageDiffError.name }, { name: NoRefImageError.name }, { foo: "bar" }];
const obj = [
{ name: ImageDiffError.name },
{ name: NoRefImageError.name, currImg: {}, refImg: {} },
{ foo: "bar" },
];

const results = AssertViewResults.fromRawObject(obj).get();

Expand Down
4 changes: 2 additions & 2 deletions test/src/runner/test-runner/insistant-test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ describe("runner/test-runner/insistant-test-runner", () => {
onEachTestRun_(innerRunner => {
const test = new Test({});
test.err = new AssertViewError();
test.assertViewResults = [new NoRefImageError()];
test.assertViewResults = [new NoRefImageError("some-state", {}, {})];

innerRunner.emit(Events.TEST_FAIL, test);
});
Expand All @@ -243,7 +243,7 @@ describe("runner/test-runner/insistant-test-runner", () => {
onFirstTestRun_(innerRunner => {
const test = new Test({});
test.err = new Error();
test.assertViewResults = [new NoRefImageError()];
test.assertViewResults = [new NoRefImageError("some-state", {}, {})];

innerRunner.emit(Events.TEST_FAIL, test);
});
Expand Down

0 comments on commit 31ceb6f

Please sign in to comment.