Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/architecture/dependency-rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ import { describe, expect, it } from "vitest";

const root = fileURLToPath(new URL("../..", import.meta.url));
const fixture = fileURLToPath(new URL("../fixtures/depcruise", import.meta.url));
const bin = `${root}node_modules/.bin/depcruise`;
// Node runs the package's own entry: `node_modules/.bin/depcruise` is a POSIX shell shim that Windows
// cannot spawn without a shell (ENOENT, #78).
const bin = `${root}node_modules/dependency-cruiser/bin/dependency-cruiser.mjs`;

// Runs the real dependency-cruiser with the project's config against a fixture tree that
// contains one deliberate deep import across modules.
function cruise(entry: string) {
const result = spawnSync(bin, [entry, "--config", `${root}.dependency-cruiser.cjs`, "--no-progress", "--output-type", "err"], {
const result = spawnSync(process.execPath, [bin, entry, "--config", `${root}.dependency-cruiser.cjs`, "--no-progress", "--output-type", "err"], {
cwd: fixture,
encoding: "utf8",
});
return { status: result.status, output: `${result.stdout}${result.stderr}` };
}

describe("module boundary rules", () => {
// Each case starts a real dependency-cruiser run: up to ~5 s on Windows (#87 review), ~1 s on Linux CI.
describe("module boundary rules", { timeout: 20_000 }, () => {
it("rejects a deep import into another module's internals", () => {
const { status, output } = cruise("src/features/alpha");

Expand Down
Loading