File tree Expand file tree Collapse file tree 1 file changed +18
-12
lines changed Expand file tree Collapse file tree 1 file changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -101,21 +101,27 @@ function runTest(
101
101
expectedError : string | undefined ,
102
102
skipped : boolean
103
103
) : void {
104
+ let error : unknown = null ;
105
+ let result : string | null | undefined ;
106
+
107
+ try {
108
+ result = runTransform ( input , testPath ) ;
109
+ } catch ( e : unknown ) {
110
+ error = e ;
111
+ }
112
+
104
113
if ( expectedError ) {
105
- // IDG why expect().toThrow() doesn't work here but whatever
106
- let errorCount = 0 ;
107
- try {
108
- runTransform ( input , testPath ) ;
109
- } catch ( e : unknown ) {
110
- errorCount ++ ;
111
- assert ( e instanceof Error , 'expected e to be an Error' ) ;
112
- expect ( `${ e . name } : ${ squish ( e . message ) } ` ) . toEqual ( squish ( expectedError ) ) ;
113
- }
114
- expect ( errorCount ) . toEqual ( 1 ) ;
114
+ expect ( result ) . toBeUndefined ( ) ;
115
+ assert ( error instanceof Error , 'expected e to be an Error' ) ;
116
+ expect ( `${ error . name } : ${ squish ( error . message ) } ` ) . toEqual (
117
+ squish ( expectedError )
118
+ ) ;
115
119
} else if ( skipped ) {
116
- expect ( runTransform ( input , testPath ) ) . toBeUndefined ( ) ;
120
+ expect ( error ) . toBeNull ( ) ;
121
+ expect ( result ) . toEqual ( '' ) ; // applyTransform coerces undefined to ''
117
122
} else {
118
- expect ( runTransform ( input , testPath ) ) . toEqual ( output . trim ( ) ) ;
123
+ expect ( error ) . toBeNull ( ) ;
124
+ expect ( result ) . toEqual ( output . trim ( ) ) ;
119
125
}
120
126
}
121
127
You can’t perform that action at this time.
0 commit comments