blob: 74a744a7d8ba37ab70b83d67001025e5e4aae956 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Bun Test</title>
</head>
<body>
<script type="module">
globalThis.getModuleScriptSrc = async (name) => {
const response = await fetch(name, {
cache: "force-cache",
});
if (response.ok) {
return await response.text();
} else {
throw new Error(`Failed to get module script ${name}`);
}
};
globalThis.runTest = async (name) => {
var Namespace = await import(name);
var testFunction = Namespace.test;
if (
!("test" in Namespace) &&
"default" in Namespace &&
typeof Namespace.default === "function"
) {
Namespace = Namespace.default();
testFunction = Namespace.test;
}
if (!testFunction) {
throw new Error("No test function found in " + name);
}
if (typeof testFunction !== "function") {
throw new Error(
`Expected (await import(\"${name}\"")) to have a test function.\nReceived: ${Object.keys(
Namespace
).join(", ")} `
);
}
return await testFunction();
};
</script>
</body>
</html>
|