Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions .changeset/colocate-vitest-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@tailor-platform/sdk": patch
---

Colocate `src/vitest/` tests next to their sources (drop the
`src/vitest/__tests__/` directory). Vitest discovers the test files
via the existing `**/?(*.)+(spec|test).ts` include pattern, so the
`**/__tests__/**/*.ts` entry has been removed from `vitest.config.ts`.
The nested integration runner moves from
`src/vitest/__tests__/integration/` to `src/vitest/integration/`. Pure
refactor: no public API or behavior changes.
2 changes: 2 additions & 0 deletions packages/sdk/knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"ignore": [
"scripts/**",
"e2e/fixtures/**",
"eslint-rules/__tests__/fixtures/**",
"src/cli/commands/deploy/__test_fixtures__/**",
"src/types/*.ts",
"src/vitest/integration/vitest.config.ts",
"zinfer.config.ts"
],
"ignoreDependencies": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from "vitest";
import { getBlockedMessage, isBlockedModule } from "../blocked-modules";
import { getBlockedMessage, isBlockedModule } from "./blocked-modules";

describe("isBlockedModule", () => {
test("recognizes node:-prefixed builtins", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { isAbsolute } from "node:path";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { tailorRuntime } from "../index";
import { tailorRuntime } from "./index";

describe("tailorRuntime", () => {
const ENV_VAR = "__TAILOR_RUNTIME_CONFIG";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const configPath = resolve(integrationDir, "vitest.config.ts");
// Run the nested `vitest run` from the SDK package root (not src/) so the
// subprocess sees the package's `package.json` and `tsconfig.json` for
// module resolution and TS transforms.
const sdkDir = resolve(currentDir, "../../..");
const sdkDir = resolve(currentDir, "../..");

// Resolve the workspace's installed Vitest entry rather than relying on `npx`,
// which may perform online package resolution and slow down / destabilize CI.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vitest/config";
import { createBlockPlugin } from "../../plugin";
import { createBlockPlugin } from "../plugin";

const here = dirname(fileURLToPath(import.meta.url));

export default defineConfig({
plugins: [createBlockPlugin()],
test: {
watch: false,
environment: resolve(here, "../../environment.ts"),
setupFiles: [resolve(here, "../../setup.ts")],
environment: resolve(here, "../environment.ts"),
setupFiles: [resolve(here, "../setup.ts")],
include: ["./**/*.test.ts"],
root: here,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* and are intentionally omitted because they would always pass.
*/
import { afterAll, beforeAll, describe, expectTypeOf, test } from "vitest";
import { injectMocks, cleanupMocks } from "../mock";
import { injectMocks, cleanupMocks } from "./mock";

beforeAll(() => injectMocks(globalThis));
afterAll(() => cleanupMocks(globalThis));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
cleanupMocks,
STATE_KEY,
RUNTIME_FLAG_KEY,
} from "../mock";
} from "./mock";

describe("mock", () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { isAbsolute } from "node:path";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { createBlockPlugin, createEnvironmentPlugin } from "../plugin";
import { createBlockPlugin, createEnvironmentPlugin } from "./plugin";

type ImportNode = {
type: "ImportDeclaration" | "ExportNamedDeclaration" | "ExportAllDeclaration";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
loadSecretsFromConfig,
removeBlockedGlobals,
restoreBlockedGlobals,
} from "../setup";
} from "./setup";

describe("extractVaultStore", () => {
test("unwraps a defineSecretManager() shape via the .vaults field", () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/sdk/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ export default defineConfig({
extends: true,
test: {
name: "unit",
include: ["**/__tests__/**/*.ts", "**/?(*.)+(spec|test).ts"],
include: ["**/?(*.)+(spec|test).ts"],
exclude: [
"**/node_modules/**",
"**/dist/**",
"e2e/**",
"**/__test_fixtures__/**",
"**/__tests__/fixtures/**",
"src/plugin/compat.test.ts",
"src/vitest/__tests__/integration/**",
"src/vitest/integration/**",
],
},
},
Expand Down
Loading