-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Expand file tree
/
Copy pathvitest.workspace.mts
More file actions
63 lines (62 loc) · 2.53 KB
/
Copy pathvitest.workspace.mts
File metadata and controls
63 lines (62 loc) · 2.53 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
import { svelte, vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { defineWorkspace } from 'vitest/config';
/**
* Two projects, one command (`npm test` still runs everything).
*
* The split exists because of exactly one suite. `ui-package.test.ts` mounts
* `@colbymchenry/codegraph-ui`'s components against a mock adapter (task
* CG-61), and to do that it needs three things the engine's suites must never
* see:
*
* - the **Svelte plugin**, to compile `.svelte` and `.svelte.ts` modules;
* - **jsdom**, because a component without a document is not a render;
* - `resolve.conditions: ['browser']`, so `svelte` resolves to its client
* build rather than its server one (`mount()` throws on the server).
*
* That last one is why this is a workspace rather than one config with a
* couple of extra fields. `browser` is a package-resolution condition, not a
* test setting: applied globally it would also hand the engine's suites the
* browser builds of `web-tree-sitter` and friends, and the failures that
* causes look nothing like their cause.
*
* The engine project `extends` the shared base, so the env vars and Node guard
* in `vitest.config.mts` still apply to every engine test. The ui project does
* not — see the note on it.
*/
export default defineWorkspace([
{
extends: './vitest.config.mts',
test: {
name: 'engine',
include: ['__tests__/**/*.test.ts'],
exclude: ['**/node_modules/**', '**/dist/**', '__tests__/ui-package.test.ts'],
},
},
{
// Deliberately NOT `extends`: a workspace project CONCATENATES the base's
// `include` with its own, so extending here would run all 200-odd engine
// suites a second time inside jsdom (and two of them fail there, for
// reasons that have nothing to do with anything). This project stands
// alone, and it needs none of the base's spawn-related env anyway.
plugins: [
// The same preprocessor `ui/svelte.config.js` builds with, so the test
// compiles what the package ships.
svelte({ preprocess: vitePreprocess() }),
],
resolve: { conditions: ['browser'] },
test: {
name: 'ui',
globals: true,
include: ['__tests__/ui-package.test.ts'],
environment: 'jsdom',
server: {
deps: {
// `@xyflow/svelte` ships uncompiled `.svelte` files, so it has to go
// through the plugin above rather than be externalised to Node,
// which has no idea what a `.svelte` file is.
inline: [/@xyflow\/svelte/],
},
},
},
},
]);