Skip to content

Commit

Permalink
FI-1471 fix: error.setMessage method in UI-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
uid11 committed Oct 14, 2024
1 parent 129ad87 commit f10d68b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/utils/expect/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ export type ExpectMethod = (this: Expect, ...args: readonly unknown[]) => Promis
/**
* All matchers.
*/
// TODO: support LocatorAssertions, is Actual is a Selector
// TODO: support LocatorAssertions, if Actual is a Selector
export type Matchers<Actual> = AdditionalMatchers<Actual> & ReturnType<PlaywrightExpect>;
7 changes: 6 additions & 1 deletion src/utils/uiMode/fixSourceCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ if (isUiMode) {

setReadonlyProperty(Error, 'prototype', OriginalError.prototype);

globalThis.Error.prototype.constructor = Error;
Object.assign(globalThis.Error.prototype, {
constructor: Error,
setMessage(this: {message: string}, message: string) {
this.message = message;
},
});

// eslint-disable-next-line @typescript-eslint/unbound-method
Error.captureStackTrace = OriginalError.captureStackTrace;
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"esModuleInterop": true,
"exactOptionalPropertyTypes": true,
"incremental": true,
"isolatedDeclarations": true,
"module": "CommonJS",
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
Expand Down

0 comments on commit f10d68b

Please sign in to comment.