Skip to content

Commit 28cccef

Browse files
committed
refactor: wip
1 parent 56c04db commit 28cccef

File tree

5 files changed

+27
-159
lines changed

5 files changed

+27
-159
lines changed

packages/cli/mocks/configs/code-pushup.config.js

Lines changed: 0 additions & 43 deletions
This file was deleted.

packages/cli/mocks/configs/code-pushup.config.mjs

Lines changed: 0 additions & 43 deletions
This file was deleted.

packages/cli/mocks/core-config-middleware.int-helper.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

testing/test-setup-config/src/lib/vitest-config-factory.unit.test.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
import type { E2ETestOptions, TestKind } from './vitest-config-factory.js';
1+
import {
2+
type E2ETestOptions,
3+
type TestKind,
4+
createVitestConfig,
5+
} from './vitest-config-factory.js';
26

3-
const tsconfigPathAliasesMock = vi.hoisted(() => ({
7+
vi.mock('./vitest-tsconfig-path-aliases.js', () => ({
48
tsconfigPathAliases: vi
59
.fn()
610
.mockReturnValue([{ find: '@test/alias', replacement: '/mock/path' }]),
711
}));
812

9-
vi.mock('./vitest-tsconfig-path-aliases.js', () => tsconfigPathAliasesMock);
10-
1113
describe('createVitestConfig', () => {
12-
let createVitestConfig: typeof import('./vitest-config-factory.js').createVitestConfig;
13-
14-
beforeEach(async () => {
15-
vi.clearAllMocks();
16-
({ createVitestConfig } = await import('./vitest-config-factory.js'));
17-
});
1814
describe('unit test configuration', () => {
1915
it('should create a complete unit test config with all defaults', () => {
2016
const config = createVitestConfig('test-package', 'unit');
@@ -143,9 +139,6 @@ describe('createVitestConfig', () => {
143139
const config = createVitestConfig('test-package', 'int');
144140

145141
const setupFiles = config.test!.setupFiles;
146-
expect(setupFiles).toContain(
147-
'../../testing/test-setup/src/lib/jiti.int-setup.ts',
148-
);
149142
expect(setupFiles).toContain(
150143
'../../testing/test-setup/src/lib/logger.mock.ts',
151144
);

testing/test-setup-config/src/lib/vitest-setup-presets.unit.test.ts

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
const configFactoryMock = vi.hoisted(() => ({
1+
import * as configFactory from './vitest-config-factory.js';
2+
import {
3+
createE2ETestConfig,
4+
createIntTestConfig,
5+
createUnitTestConfig,
6+
} from './vitest-setup-presets.js';
7+
8+
vi.mock('./vitest-config-factory.js', () => ({
29
createVitestConfig: vi.fn().mockReturnValue('mocked-config'),
310
}));
411

5-
vi.mock('./vitest-config-factory.js', () => configFactoryMock);
6-
712
const MOCK_PROJECT_KEY = 'test-package';
813

914
describe('vitest-setup-presets', () => {
10-
let createUnitTestConfig: typeof import('./vitest-setup-presets.js').createUnitTestConfig;
11-
let createIntTestConfig: typeof import('./vitest-setup-presets.js').createIntTestConfig;
12-
let createE2ETestConfig: typeof import('./vitest-setup-presets.js').createE2ETestConfig;
13-
14-
beforeEach(async () => {
15+
beforeEach(() => {
1516
vi.clearAllMocks();
16-
({ createUnitTestConfig, createIntTestConfig, createE2ETestConfig } =
17-
await import('./vitest-setup-presets.js'));
1817
});
1918

2019
describe('createUnitTestConfig', () => {
2120
it('should call createVitestConfig with unit kind', () => {
2221
const result = createUnitTestConfig(MOCK_PROJECT_KEY);
2322

24-
expect(configFactoryMock.createVitestConfig).toHaveBeenCalledWith(
23+
expect(configFactory.createVitestConfig).toHaveBeenCalledWith(
2524
MOCK_PROJECT_KEY,
2625
'unit',
2726
);
@@ -31,7 +30,7 @@ describe('vitest-setup-presets', () => {
3130
it('should handle different project names', () => {
3231
createUnitTestConfig('my-custom-package');
3332

34-
expect(configFactoryMock.createVitestConfig).toHaveBeenCalledWith(
33+
expect(configFactory.createVitestConfig).toHaveBeenCalledWith(
3534
'my-custom-package',
3635
'unit',
3736
);
@@ -40,18 +39,15 @@ describe('vitest-setup-presets', () => {
4039
it('should handle empty projectKey', () => {
4140
createUnitTestConfig('');
4241

43-
expect(configFactoryMock.createVitestConfig).toHaveBeenCalledWith(
44-
'',
45-
'unit',
46-
);
42+
expect(configFactory.createVitestConfig).toHaveBeenCalledWith('', 'unit');
4743
});
4844
});
4945

5046
describe('createIntTestConfig', () => {
5147
it('should call createVitestConfig with int kind', () => {
5248
const result = createIntTestConfig(MOCK_PROJECT_KEY);
5349

54-
expect(configFactoryMock.createVitestConfig).toHaveBeenCalledWith(
50+
expect(configFactory.createVitestConfig).toHaveBeenCalledWith(
5551
MOCK_PROJECT_KEY,
5652
'int',
5753
);
@@ -61,7 +57,7 @@ describe('vitest-setup-presets', () => {
6157
it('should handle different project names', () => {
6258
createIntTestConfig('integration-package');
6359

64-
expect(configFactoryMock.createVitestConfig).toHaveBeenCalledWith(
60+
expect(configFactory.createVitestConfig).toHaveBeenCalledWith(
6561
'integration-package',
6662
'int',
6763
);
@@ -72,7 +68,7 @@ describe('vitest-setup-presets', () => {
7268
it('should call createVitestConfig with e2e kind and no options', () => {
7369
const result = createE2ETestConfig(MOCK_PROJECT_KEY);
7470

75-
expect(configFactoryMock.createVitestConfig).toHaveBeenCalledWith(
71+
expect(configFactory.createVitestConfig).toHaveBeenCalledWith(
7672
MOCK_PROJECT_KEY,
7773
'e2e',
7874
undefined,
@@ -87,7 +83,7 @@ describe('vitest-setup-presets', () => {
8783

8884
createE2ETestConfig(MOCK_PROJECT_KEY, options);
8985

90-
expect(configFactoryMock.createVitestConfig).toHaveBeenCalledWith(
86+
expect(configFactory.createVitestConfig).toHaveBeenCalledWith(
9187
MOCK_PROJECT_KEY,
9288
'e2e',
9389
options,
@@ -97,7 +93,7 @@ describe('vitest-setup-presets', () => {
9793
it('should handle testTimeout option', () => {
9894
createE2ETestConfig(MOCK_PROJECT_KEY, { testTimeout: 30_000 });
9995

100-
expect(configFactoryMock.createVitestConfig).toHaveBeenCalledWith(
96+
expect(configFactory.createVitestConfig).toHaveBeenCalledWith(
10197
MOCK_PROJECT_KEY,
10298
'e2e',
10399
{ testTimeout: 30_000 },
@@ -119,17 +115,17 @@ describe('vitest-setup-presets', () => {
119115
createIntTestConfig('pkg2');
120116
createE2ETestConfig('pkg3');
121117

122-
expect(configFactoryMock.createVitestConfig).toHaveBeenNthCalledWith(
118+
expect(configFactory.createVitestConfig).toHaveBeenNthCalledWith(
123119
1,
124120
'pkg1',
125121
'unit',
126122
);
127-
expect(configFactoryMock.createVitestConfig).toHaveBeenNthCalledWith(
123+
expect(configFactory.createVitestConfig).toHaveBeenNthCalledWith(
128124
2,
129125
'pkg2',
130126
'int',
131127
);
132-
expect(configFactoryMock.createVitestConfig).toHaveBeenNthCalledWith(
128+
expect(configFactory.createVitestConfig).toHaveBeenNthCalledWith(
133129
3,
134130
'pkg3',
135131
'e2e',
@@ -144,7 +140,7 @@ describe('vitest-setup-presets', () => {
144140
e2e: { test: 'e2e-config' },
145141
};
146142

147-
vi.mocked(configFactoryMock.createVitestConfig)
143+
vi.mocked(configFactory.createVitestConfig)
148144
.mockReturnValueOnce(mockConfigs.unit as any)
149145
.mockReturnValueOnce(mockConfigs.int as any)
150146
.mockReturnValueOnce(mockConfigs.e2e as any);

0 commit comments

Comments
 (0)