Skip to content

Commit 20c4332

Browse files
authored
Merge pull request #80 from armano2/chore/simplify-assertThrows
chore: remove yerror from dependencies and use jest.expect
2 parents 50ad245 + 0cedeb1 commit 20c4332

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

package-lock.json

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,6 @@
142142
"trailingComma": "all",
143143
"proseWrap": "always"
144144
},
145-
"dependencies": {
146-
"yerror": "^8.0.0"
147-
},
148145
"jest": {
149146
"coverageReporters": [
150147
"lcov"

src/tests/testUtils.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
import { expect } from '@jest/globals';
2-
import { YError } from 'yerror';
32

4-
export function assertThrows<T>(
5-
fn: () => void,
6-
type: T,
7-
message: string,
8-
) {
9-
try {
10-
fn();
11-
throw new YError('E_UNEXPECTED_SUCCESS');
12-
} catch (err) {
13-
expect(err).toBeInstanceOf(type);
14-
expect((err as Error).message).toEqual(message);
15-
}
3+
export function assertThrows<T>(fn: () => void, type: T, message: string) {
4+
const expRes = expect(fn);
5+
expRes.toThrowError(message);
6+
expRes.toThrow(type);
167
}

0 commit comments

Comments
 (0)