production-tests
7nik 2 months ago
parent f5ea3ad8d9
commit 872fa3a66c

@ -1,6 +1,6 @@
<script> <script>
import { DEV } from "esm-env"; import { DEV } from "esm-env";
console.info("prod", DEV)
if (DEV) { if (DEV) {
throw new Error("Dev-only code must not run"); throw new Error("Dev-only code must not run");
} }

@ -41,20 +41,18 @@ export function suite<Test extends BaseTest>(fn: (config: Test, test_dir: string
} }
}); });
if (production_tests.length) { let mocked = false;
let mocked = false; for (const [it, name, test] of production_tests) {
for (const [it, name, test] of production_tests) { it(name, () => {
it(name, () => { if (!mocked) {
if (!mocked) { vi.doMock('esm-env', async (importEnv) => ({
vi.doMock('esm-env', async (importEnv) => ({ ...(await importEnv()),
...(await importEnv()), DEV: false
DEV: false }));
})); mocked = true;
mocked = true; }
} return test();
return test(); });
});
}
} }
} }
}; };
@ -99,20 +97,18 @@ export function suite_with_variants<Test extends BaseTest, Variants extends stri
} }
}); });
if (production_tests.length) { let mocked = false;
let mocked = false; for (const [it, name, test] of production_tests) {
for (const [it, name, test] of production_tests) { it(name, () => {
it(name, () => { if (!mocked) {
if (!mocked) { vi.doMock('esm-env', async (importEnv) => ({
vi.doMock('esm-env', async (importEnv) => ({ ...(await importEnv()),
...(await importEnv()), DEV: false
DEV: false }));
})); mocked = true;
mocked = true; }
} return test();
return test(); });
});
}
} }
} }
}; };

Loading…
Cancel
Save