mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 21:54:09 +00:00
test(vitest): classify Crabbox shared dependencies
This commit is contained in:
@@ -219,6 +219,29 @@ describe("base vitest config", () => {
|
||||
/(?:^|\/)test\/non-isolated-runner\.ts$/u,
|
||||
);
|
||||
});
|
||||
|
||||
it("classifies Crabbox shared dependencies as external dependencies", () => {
|
||||
expect(baseConfig.test?.deps?.moduleDirectories).toEqual([
|
||||
"/node_modules/",
|
||||
"/openclaw-pnpm-node-modules/",
|
||||
]);
|
||||
|
||||
const externalPatterns = baseConfig.test?.server?.deps?.external ?? [];
|
||||
expect(
|
||||
externalPatterns.some(
|
||||
(pattern) =>
|
||||
pattern instanceof RegExp &&
|
||||
pattern.test("/tmp/openclaw-pnpm-node-modules/some-dep/dist/index.mjs"),
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
externalPatterns.some(
|
||||
(pattern) =>
|
||||
pattern instanceof RegExp &&
|
||||
pattern.test("/tmp/openclaw-pnpm-node-modules/vite/dist/client/env.mjs"),
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("test scripts", () => {
|
||||
|
||||
@@ -138,6 +138,10 @@ const workerConfig = resolveSharedVitestWorkerConfig({
|
||||
isWindows,
|
||||
localScheduling,
|
||||
});
|
||||
const dependencyModuleDirectories = ["/node_modules/", "/openclaw-pnpm-node-modules/"];
|
||||
const dependencyExternalPatterns = [
|
||||
/\/openclaw-pnpm-node-modules\/(?!.*\/?vite\w*\/dist\/client\/env\.mjs$).*\.(?:cjs\.js|mjs)$/u,
|
||||
];
|
||||
const sourcePluginSdkSubpaths = [
|
||||
...new Set([...pluginSdkSubpaths, ...privateLocalOnlyPluginSdkSubpaths]),
|
||||
].toSorted((left, right) => left.localeCompare(right));
|
||||
@@ -436,6 +440,14 @@ export const sharedVitestConfig = {
|
||||
runner: nonIsolatedRunnerPath,
|
||||
maxWorkers: workerConfig.maxWorkers,
|
||||
fileParallelism: workerConfig.fileParallelism,
|
||||
deps: {
|
||||
moduleDirectories: dependencyModuleDirectories,
|
||||
},
|
||||
server: {
|
||||
deps: {
|
||||
external: dependencyExternalPatterns,
|
||||
},
|
||||
},
|
||||
forceRerunTriggers: [
|
||||
"package.json",
|
||||
"pnpm-lock.yaml",
|
||||
|
||||
Reference in New Issue
Block a user