File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
turbopack/crates/turbopack-tests/tests/execution/turbopack/evaluation-errors/basic/input Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ it ( 'module evaluation rethrows but does not re-evaluate' , async ( ) => {
2
+ expect ( globalThis . evalCounter ) . toBeUndefined ( )
3
+ await assertThrowsThrows ( )
4
+ expect ( globalThis . evalCounter ) . toBe ( 1 )
5
+ await assertThrowsThrows ( )
6
+ expect ( globalThis . evalCounter ) . toBe ( 1 )
7
+
8
+ // We do re-evaluate if the module cache is cleared
9
+ require . cache [ require . resolve ( './throws' ) ] = undefined
10
+ await assertThrowsThrows ( )
11
+ expect ( globalThis . evalCounter ) . toBe ( 2 )
12
+ await assertThrowsThrows ( )
13
+ expect ( globalThis . evalCounter ) . toBe ( 2 )
14
+ } )
15
+
16
+ async function assertThrowsThrows ( ) {
17
+ try {
18
+ await import ( './throws' )
19
+ } catch ( e ) {
20
+ return e
21
+ }
22
+ throw new Error ( 'should have thrown' )
23
+ }
Original file line number Diff line number Diff line change
1
+ globalThis . evalCounter ??= 0
2
+ globalThis . evalCounter ++
3
+
4
+ throw new Error ( 'uh oh' )
You can’t perform that action at this time.
0 commit comments