Skip to content

Commit ec0e825

Browse files
authored
Merge pull request #5216 from aryaemami59/chore/toolkit/remove-areErrorsEqual
chore(toolkit): remove unnecessary `areErrorsEqual` function
2 parents b98a8cc + d4604cc commit ec0e825

1 file changed

Lines changed: 0 additions & 40 deletions

File tree

packages/toolkit/vitest.setup.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,6 @@ vi.stubGlobal('fetch', nodeFetch)
55
vi.stubGlobal('Request', Request)
66
vi.stubGlobal('Headers', Headers)
77

8-
/**
9-
* Compares two values to determine if they are instances of {@linkcode Error}
10-
* and have the same {@linkcode Error.name | name}
11-
* and {@linkcode Error.message | message} properties.
12-
*
13-
* @param actualError - The actual error to compare.
14-
* @param expectedError - The expected error to compare against.
15-
* @returns `true` if both values are instances of {@linkcode Error} and have the same {@linkcode Error.name | name} and {@linkcode Error.message | message}.
16-
*
17-
* @example
18-
* <caption>#### __Pass: The actual error is an instance of `TypeError` with the same `message` ✔️__</caption>
19-
*
20-
* ```ts
21-
* expect(consoleErrorSpy).toHaveBeenLastCalledWith(
22-
* TypeError('endpointDefinition.queryFn is not a function'),
23-
* )
24-
* ```
25-
*
26-
* @example
27-
* <caption>#### __Fail: The actual error is a `TypeError`, which is more specific than the expected generic `Error` ❌__</caption>
28-
*
29-
* ```ts
30-
* expect(consoleErrorSpy).toHaveBeenLastCalledWith(
31-
* Error('endpointDefinition.queryFn is not a function'),
32-
* )
33-
* ```
34-
*
35-
* @internal
36-
*/
37-
const areErrorsEqual = (actualError: unknown, expectedError: unknown) => {
38-
if (actualError instanceof Error && expectedError instanceof Error) {
39-
return (
40-
actualError.name === expectedError.name &&
41-
actualError.message === expectedError.message
42-
)
43-
}
44-
}
45-
46-
expect.addEqualityTesters([areErrorsEqual])
47-
488
beforeAll(() => {
499
server.listen({ onUnhandledRequest: 'error' })
5010
})

0 commit comments

Comments
 (0)