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 () => {
1616} ) ;
1717
1818test ( '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} ) ;
Original file line number Diff line number Diff line change @@ -47,17 +47,10 @@ test('find an inline source map', async () => {
4747} ) ;
4848
4949test ( '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} ) ;
Original file line number Diff line number Diff line change 88import { parse } from '../../utils/parser' ;
99
1010test ( '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
2016test ( '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} ) ;
You can’t perform that action at this time.
0 commit comments