Skip to content

Commit 6be1bac

Browse files
committed
Decouple test helpers from production src
1 parent edc914b commit 6be1bac

File tree

25 files changed

+118
-31
lines changed

25 files changed

+118
-31
lines changed

cli/src/__tests__/utils/env.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, test, expect, afterEach } from 'bun:test'
22

3-
import { createTestCliEnv } from '../../testing/env'
3+
import { createTestCliEnv } from '../../../testing/env'
44
import { getCliEnv } from '../../utils/env'
55

66
describe('cli/utils/env', () => {
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { createTestBaseEnv } from '@codebuff/common/testing/env-process'
66

7-
import type { CliEnv } from '../types/env'
7+
import type { CliEnv } from '../src/types/env'
88

99
/**
1010
* Create a test CliEnv with optional overrides.
@@ -45,4 +45,3 @@ export const createTestCliEnv = (overrides: Partial<CliEnv> = {}): CliEnv => ({
4545
CODEBUFF_SCROLL_MULTIPLIER: undefined,
4646
...overrides,
4747
})
48-

cli/tsconfig.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,14 @@
1717
}
1818
},
1919
"include": ["src/**/*"],
20-
"exclude": ["node_modules", "dist"]
20+
"exclude": [
21+
"node_modules",
22+
"dist",
23+
"src/**/__tests__/**",
24+
"src/**/__mocks__/**",
25+
"src/**/*.test.ts",
26+
"src/**/*.test.tsx",
27+
"src/**/*.spec.ts",
28+
"src/**/*.spec.tsx"
29+
]
2130
}

common/package.json

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,40 @@
1212
"default": "./src/*.ts"
1313
},
1414
"./testing/fixtures": {
15-
"bun": "./src/testing/fixtures/index.ts",
16-
"import": "./src/testing/fixtures/index.ts",
17-
"types": "./src/testing/fixtures/index.ts",
18-
"default": "./src/testing/fixtures/index.ts"
15+
"bun": "./testing/fixtures/index.ts",
16+
"import": "./testing/fixtures/index.ts",
17+
"types": "./testing/fixtures/index.ts",
18+
"default": "./testing/fixtures/index.ts"
19+
},
20+
"./testing/fixtures/*": {
21+
"bun": "./testing/fixtures/*.ts",
22+
"import": "./testing/fixtures/*.ts",
23+
"types": "./testing/fixtures/*.ts",
24+
"default": "./testing/fixtures/*.ts"
25+
},
26+
"./testing/env-process": {
27+
"bun": "./testing/env-process.ts",
28+
"import": "./testing/env-process.ts",
29+
"types": "./testing/env-process.ts",
30+
"default": "./testing/env-process.ts"
31+
},
32+
"./testing/env-ci": {
33+
"bun": "./testing/env-ci.ts",
34+
"import": "./testing/env-ci.ts",
35+
"types": "./testing/env-ci.ts",
36+
"default": "./testing/env-ci.ts"
37+
},
38+
"./testing/mock-modules": {
39+
"bun": "./testing/mock-modules.ts",
40+
"import": "./testing/mock-modules.ts",
41+
"types": "./testing/mock-modules.ts",
42+
"default": "./testing/mock-modules.ts"
43+
},
44+
"./testing/impl/*": {
45+
"bun": "./testing/impl/*.ts",
46+
"import": "./testing/impl/*.ts",
47+
"types": "./testing/impl/*.ts",
48+
"default": "./testing/impl/*.ts"
1949
}
2050
},
2151
"scripts": {

common/src/__tests__/env-ci.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, test, expect, afterEach } from 'bun:test'
22

33
import { getCiEnv, ciEnv, isCI } from '../env-ci'
4-
import { createTestCiEnv } from '../testing/env-ci'
4+
import { createTestCiEnv } from '../../testing/env-ci'
55

66
describe('env-ci', () => {
77
describe('getCiEnv', () => {

common/src/__tests__/env-process.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, test, expect, afterEach } from 'bun:test'
22

33
import { getProcessEnv, processEnv } from '../env-process'
4-
import { createTestProcessEnv } from '../testing/env-process'
4+
import { createTestProcessEnv } from '../../testing/env-process'
55

66
describe('env-process', () => {
77
describe('getProcessEnv', () => {
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Test-only CiEnv fixtures.
33
*/
44

5-
import type { CiEnv } from '../types/contracts/env'
5+
import type { CiEnv } from '../src/types/contracts/env'
66

77
/**
88
* Create a test CiEnv with optional overrides.
@@ -16,4 +16,3 @@ export const createTestCiEnv = (overrides: Partial<CiEnv> = {}): CiEnv => ({
1616
CODEBUFF_API_KEY: 'test-api-key',
1717
...overrides,
1818
})
19-
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Test-only ProcessEnv fixtures.
33
*/
44

5-
import type { BaseEnv, ProcessEnv } from '../types/contracts/env'
5+
import type { BaseEnv, ProcessEnv } from '../src/types/contracts/env'
66

77
/**
88
* Create test defaults for BaseEnv.
@@ -84,4 +84,3 @@ export const createTestProcessEnv = (
8484
OVERRIDE_ARCH: undefined,
8585
...overrides,
8686
})
87-

common/src/testing/fixtures/agent-runtime.ts renamed to common/testing/fixtures/agent-runtime.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
import { spyOn } from 'bun:test'
99

10-
import type { AgentTemplate } from '../../types/agent-template'
10+
import type { AgentTemplate } from '../../src/types/agent-template'
1111
import type {
1212
AgentRuntimeDeps,
1313
AgentRuntimeScopedDeps,
14-
} from '../../types/contracts/agent-runtime'
15-
import type { ClientEnv, CiEnv } from '../../types/contracts/env'
16-
import type { Logger } from '../../types/contracts/logger'
14+
} from '../../src/types/contracts/agent-runtime'
15+
import type { ClientEnv, CiEnv } from '../../src/types/contracts/env'
16+
import type { Logger } from '../../src/types/contracts/logger'
1717

1818
export const testLogger: Logger = {
1919
debug: () => {},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* These helpers create properly-typed mocks without requiring ugly `as unknown as` casts.
66
*/
77

8-
import type { Logger } from '../../types/contracts/logger'
8+
import type { Logger } from '../../src/types/contracts/logger'
99

1010
// Re-export the test logger for convenience
1111
export { testLogger } from './agent-runtime'

0 commit comments

Comments
 (0)