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

@ -1,6 +1,6 @@
<script>
import { DEV } from "esm-env";
console.info("prod", DEV)
if (DEV) {
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;
for (const [it, name, test] of production_tests) {
it(name, () => {
if (!mocked) {
vi.doMock('esm-env', async (importEnv) => ({
...(await importEnv()),
DEV: false
}));
mocked = true;
}
return test();
});
}
let mocked = false;
for (const [it, name, test] of production_tests) {
it(name, () => {
if (!mocked) {
vi.doMock('esm-env', async (importEnv) => ({
...(await importEnv()),
DEV: false
}));
mocked = true;
}
return test();
});
}
}
};
@ -99,20 +97,18 @@ export function suite_with_variants<Test extends BaseTest, Variants extends stri
}
});
if (production_tests.length) {
let mocked = false;
for (const [it, name, test] of production_tests) {
it(name, () => {
if (!mocked) {
vi.doMock('esm-env', async (importEnv) => ({
...(await importEnv()),
DEV: false
}));
mocked = true;
}
return test();
});
}
let mocked = false;
for (const [it, name, test] of production_tests) {
it(name, () => {
if (!mocked) {
vi.doMock('esm-env', async (importEnv) => ({
...(await importEnv()),
DEV: false
}));
mocked = true;
}
return test();
});
}
}
};

Loading…
Cancel
Save