forked from cloudflare/capnweb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
111 lines (105 loc) · 3.48 KB
/
vitest.config.ts
File metadata and controls
111 lines (105 loc) · 3.48 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit
import { defineConfig } from 'vitest/config'
export default defineConfig({
esbuild: {
target: 'es2022', // Transpile using syntax for browser compatibility
},
test: {
globalSetup: ['__tests__/test-server.ts'],
projects: [
// Node.js
{
test: {
name: 'node',
// We throw flow-control test under Node only because it's testing straightforward
// JavaScript -- no need to run it on every runtime.
include: ['__tests__/index.test.ts', '__tests__/flow-control.test.ts'],
environment: 'node',
},
},
// Cloudflare Workers
{
test: {
name: 'workerd',
include: ['__tests__/index.test.ts', '__tests__/workerd.test.ts'],
pool: '@cloudflare/vitest-pool-workers',
poolOptions: {
workers: {
miniflare: {
compatibilityDate: '2026-02-05',
// Define a backend worker to test server-side functionality. The tests will
// talk to it over a service binding. (Only the workerd client tests will talk
// to this, not Node nor browsers.)
serviceBindings: {
testServer: "test-server-workerd",
},
workers: [
{
name: "test-server-workerd",
compatibilityDate: '2026-02-05',
modules: [
{
type: "ESModule",
path: "./__tests__/test-server-workerd.js",
},
{
type: "ESModule",
path: "./dist/index-workers.js",
},
],
durableObjects: {
TEST_DO: "TestDo"
}
}
]
},
},
},
},
},
// Browsers which natively support the `using` keyword (Explicit Resource Management).
{
test: {
name: 'browsers-with-using',
include: ['__tests__/index.test.ts'],
browser: {
enabled: true,
provider: 'playwright',
instances: [
// Currently only Chromium supports this.
{ browser: 'chromium' },
],
headless: true,
screenshotFailures: false, // there's nothing to screenshot
},
},
},
// Browsers with the `using` keyword transpiled to try/catch.
{
esbuild: {
target: 'es2022',
},
test: {
name: 'browsers-without-using',
include: ['__tests__/index.test.ts'],
browser: {
enabled: true,
provider: 'playwright',
instances: [
// We re-test Chromium in this mode since it's likely users will want to serve the
// same JavaScript to all browsers, so will have to use this mode until `using`
// becomes widely available.
{ browser: 'chromium' },
{ browser: 'firefox' },
{ browser: 'webkit' },
],
headless: true,
screenshotFailures: false, // there's nothing to screenshot
},
},
},
],
},
})