MCPcopy Create free account
hub / github.com/EmNudge/watlings / transformTestForBrowser

Function transformTestForBrowser

web-build/generate.mjs:157–178  ·  view source on GitHub ↗
(testSource)

Source from the content-addressed store, hash-verified

155// ── Transform test for browser execution ────────────────────────────
156
157function transformTestForBrowser(testSource) {
158 const hasWasm = testSource.includes("getWasm");
159 let code = testSource;
160
161 // Strip multi-line imports: import { ... } from "...";
162 code = code.replace(/^import\s*\{[^}]*\}\s*from\s*["'][^"']+["'];?\s*$/gm, "");
163
164 // Strip single-line imports: import foo from "...";
165 code = code.replace(/^import\s+\w.*from\s*["'][^"']+["'];?\s*$/gm, "");
166
167 // Strip getWasm call
168 code = code.replace(/const wasmBytes = await getWasm\([^)]*\);\s*\n?/g, "");
169
170 // Strip setSuccess/setFailure calls (may span multiple lines)
171 code = code.replace(/setSuccess\([\s\S]*?\);\s*\n?/g, "");
172 code = code.replace(/setFailure\([\s\S]*?\);\s*\n?/g, "");
173
174 // Clean up excessive blank lines
175 code = code.replace(/\n{3,}/g, "\n\n").trim();
176
177 return { code, hasWasm };
178}
179
180// ── Main generation ─────────────────────────────────────────────────
181

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected