Skip to content

Commit 3679e2f

Browse files
committed
Fix linter errors in react-error-overlay tests
1 parent 7480e2d commit 3679e2f

File tree

3 files changed

+12
-36
lines changed

3 files changed

+12
-36
lines changed

packages/react-error-overlay/src/__tests__/extract-source-map.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,8 @@ test('extracts last source map directive', async () => {
1616
});
1717

1818
test('errors when no source map', async () => {
19-
expect.assertions(1);
20-
2119
const testFileName = 'test.js';
22-
try {
23-
await extractSourceMapUrl(
24-
testFileName,
25-
`console.log('hi')\n\nconsole.log('bye')`
26-
);
27-
} catch (e) {
28-
expect(e).toBe(`Cannot find a source map directive for ${testFileName}.`);
29-
}
20+
await expect(
21+
extractSourceMapUrl(testFileName, `console.log('hi')\n\nconsole.log('bye')`)
22+
).rejects.toBe(`Cannot find a source map directive for ${testFileName}.`);
3023
});

packages/react-error-overlay/src/__tests__/get-source-map.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,10 @@ test('find an inline source map', async () => {
4747
});
4848

4949
test('error on a source map with unsupported encoding', async () => {
50-
expect.assertions(2);
51-
5250
const file = fs
5351
.readFileSync(resolve(__dirname, '../../fixtures/junk-inline.mjs'))
5452
.toString('utf8');
55-
try {
56-
await getSourceMap('/', file);
57-
} catch (e) {
58-
expect(e instanceof Error).toBe(true);
59-
expect(e.message).toBe(
60-
'Sorry, non-base64 inline source-map encoding is not supported.'
61-
);
62-
}
53+
await expect(getSourceMap('/', file)).rejects.toThrow(
54+
new Error('Sorry, non-base64 inline source-map encoding is not supported.')
55+
);
6356
});

packages/react-error-overlay/src/__tests__/parser/generic.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,13 @@
88
import { parse } from '../../utils/parser';
99

1010
test('throws on null', () => {
11-
expect.assertions(2);
12-
try {
13-
parse(null);
14-
} catch (e) {
15-
expect(e instanceof Error).toBe(true);
16-
expect(e.message).toBe('You cannot pass a null object.');
17-
}
11+
expect(() => parse(null)).toThrow(
12+
new Error('You cannot pass a null object.')
13+
);
1814
});
1915

2016
test('throws on unparsable', () => {
21-
expect.assertions(2);
22-
try {
23-
parse({});
24-
} catch (e) {
25-
expect(e instanceof Error).toBe(true);
26-
expect(e.message).toBe(
27-
'The error you provided does not contain a stack trace.'
28-
);
29-
}
17+
expect(() => parse({})).toThrow(
18+
new Error('The error you provided does not contain a stack trace.')
19+
);
3020
});

0 commit comments

Comments
 (0)