@@ -13,6 +13,7 @@ import type {
1313import type { ReadyEvent } from "../../shared/src/interfaces/test-runner" ;
1414import { postCloneableMessage } from "../../shared/src/messages" ;
1515import { format } from "../../shared/src/format" ;
16+ import { createAsyncIife } from "../../shared/src/async-iife" ;
1617import { ProxyConsole } from "../../shared/src/proxy-console" ;
1718
1819const READY_MESSAGE : ReadyEvent [ "data" ] = { type : "ready" } ;
@@ -28,11 +29,6 @@ globalThis.__helpers = curriculumHelpers;
2829Object . freeze ( globalThis . __helpers ) ;
2930Object . freeze ( globalThis . assert ) ;
3031
31- // The newline is important, because otherwise comments will cause the trailing
32- // `}` to be ignored, breaking the tests.
33- const wrapCode = ( code : string ) => `(async () => {${ code } ;
34- })();` ;
35-
3632// TODO: currently this is almost identical to DOMTestEvaluator, can we make
3733// it more DRY? Don't attempt until they're both more fleshed out.
3834export class JavascriptTestEvaluator implements TestEvaluator {
@@ -50,7 +46,7 @@ export class JavascriptTestEvaluator implements TestEvaluator {
5046
5147 this . #runTest = async ( rawTest ) => {
5248 this . #proxyConsole. on ( ) ;
53- const test = wrapCode ( rawTest ) ;
49+ const test = createAsyncIife ( rawTest ) ;
5450 // This can be reassigned by the eval inside the try block, so it should be declared as a let
5551 // eslint-disable-next-line prefer-const
5652 let __userCodeWasExecuted = false ;
0 commit comments