File tree Expand file tree Collapse file tree 3 files changed +12
-36
lines changed
packages/react-error-overlay/src/__tests__ Expand file tree Collapse file tree 3 files changed +12
-36
lines changed Original file line number Diff line number Diff line change @@ -16,15 +16,8 @@ test('extracts last source map directive', async () => {
16
16
} ) ;
17
17
18
18
test ( 'errors when no source map' , async ( ) => {
19
- expect . assertions ( 1 ) ;
20
-
21
19
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 } .` ) ;
30
23
} ) ;
Original file line number Diff line number Diff line change @@ -47,17 +47,10 @@ test('find an inline source map', async () => {
47
47
} ) ;
48
48
49
49
test ( 'error on a source map with unsupported encoding' , async ( ) => {
50
- expect . assertions ( 2 ) ;
51
-
52
50
const file = fs
53
51
. readFileSync ( resolve ( __dirname , '../../fixtures/junk-inline.mjs' ) )
54
52
. 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
+ ) ;
63
56
} ) ;
Original file line number Diff line number Diff line change 8
8
import { parse } from '../../utils/parser' ;
9
9
10
10
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
+ ) ;
18
14
} ) ;
19
15
20
16
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
+ ) ;
30
20
} ) ;
You can’t perform that action at this time.
0 commit comments