-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
vitest.workspace.ts
53 lines (50 loc) · 1.42 KB
/
vitest.workspace.ts
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
52
53
import { readdir, readFile } from "fs/promises"
import { defineWorkspace } from "vitest/config"
import type { BrowserCommand } from "vitest/node"
import { base64 } from "@scure/base"
const listTestkitFiles: BrowserCommand<[]> = ({ testPath }) => {
testPath = testPath?.split("/").slice(0, -1).join("/")
return readdir((testPath ?? ".") + "/testkit")
}
const readTestkitFile: BrowserCommand<[name: string]> = async ({ testPath }, name) => {
testPath = testPath?.split("/").slice(0, -1).join("/")
return base64.encode(await readFile((testPath ?? ".") + "/testkit/" + name))
}
export default defineWorkspace([
{
test: {
name: "node",
environment: "node",
},
},
{
test: {
name: "firefox",
browser: {
enabled: true,
headless: true,
name: "firefox",
provider: "webdriverio",
commands: {
listTestkitFiles,
readTestkitFile,
},
},
},
},
{
test: {
name: "chrome",
browser: {
enabled: true,
headless: true,
name: "chrome",
provider: "webdriverio",
commands: {
listTestkitFiles,
readTestkitFile,
},
},
},
},
])