forked from Acode-Foundation/Acode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.js
More file actions
36 lines (33 loc) · 1.16 KB
/
Copy pathvitest.config.js
File metadata and controls
36 lines (33 loc) · 1.16 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
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { configDefaults, defineConfig } from "vitest/config";
const srcDir = fileURLToPath(new URL("./src", import.meta.url));
// Mirror the bundler resolution (rspack `resolve.modules: ["node_modules", "src"]`
// and tsconfig `paths: { "*": ["./src/*"] }`) so unit tests can import app
// modules via bare paths like `utils/version` or `lib/settings`.
const srcAliases = fs
.readdirSync(srcDir, { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => ({
find: new RegExp(`^${entry.name}(?:/(.*))?$`),
replacement: `${path.join(srcDir, entry.name)}/$1`,
}));
export default defineConfig({
resolve: {
alias: srcAliases,
},
test: {
// Vitest unit tests live ONLY under `tests/`.
// `src/test/` is Acode's in-app runtime test harness: it runs on-device
// inside the WebView (launched from the app commands) and depends on
// cordova/editorManager globals, so it must never be collected here.
include: ["tests/**/*.test.{js,ts}"],
exclude: [
...configDefaults.exclude,
"src/test/**",
"www/**",
"platforms/**",
],
},
});