Skip to content

Commit 4a71c54

Browse files
author
Szymon.Poltorak
committed
refactor(testing): use config factory for vitest config files
1 parent 11d7699 commit 4a71c54

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+152
-879
lines changed

e2e/cli-e2e/vitest.e2e.config.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
/// <reference types="vitest" />
2-
import { defineConfig } from 'vitest/config';
3-
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';
2+
import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js';
43

5-
export default defineConfig({
6-
cacheDir: '../../node_modules/.vite/cli-e2e',
7-
test: {
8-
reporters: ['basic'],
9-
testTimeout: 20_000,
10-
globals: true,
11-
alias: tsconfigPathAliases(),
12-
pool: 'threads',
13-
poolOptions: { threads: { singleThread: true } },
14-
cache: {
15-
dir: '../../node_modules/.vitest',
16-
},
17-
environment: 'node',
18-
include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
19-
setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'],
20-
},
4+
export default createE2ETestConfig('cli-e2e', {
5+
testTimeout: 20_000,
216
});
Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
/// <reference types="vitest" />
2-
import { defineConfig } from 'vitest/config';
3-
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';
2+
import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js';
43

5-
export default defineConfig({
6-
cacheDir: '../../node_modules/.vite/create-cli-e2e',
7-
test: {
8-
reporters: ['basic'],
9-
testTimeout: 20_000,
10-
hookTimeout: 20_000,
11-
globals: true,
12-
alias: tsconfigPathAliases(),
13-
pool: 'threads',
14-
poolOptions: { threads: { singleThread: true } },
15-
cache: {
16-
dir: '../../node_modules/.vitest',
17-
},
18-
environment: 'node',
19-
include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
20-
setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'],
21-
},
4+
export default createE2ETestConfig('create-cli-e2e', {
5+
testTimeout: 20_000,
226
});
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
/// <reference types="vitest" />
2-
import { defineConfig } from 'vitest/config';
3-
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';
2+
import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js';
43

5-
export default defineConfig({
6-
cacheDir: '../../node_modules/.vite/nx-plugin-e2e',
7-
test: {
8-
reporters: ['basic'],
9-
testTimeout: 80_000,
10-
globals: true,
11-
alias: tsconfigPathAliases(),
12-
pool: 'threads',
13-
poolOptions: { threads: { singleThread: true } },
14-
cache: {
15-
dir: '../../node_modules/.vitest',
16-
},
17-
environment: 'node',
18-
include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
19-
setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'],
20-
},
4+
export default createE2ETestConfig('nx-plugin-e2e', {
5+
testTimeout: 80_000,
216
});
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
/// <reference types="vitest" />
2-
import { defineConfig } from 'vitest/config';
3-
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';
2+
import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js';
43

5-
export default defineConfig({
6-
cacheDir: '../../node_modules/.vite/plugin-coverage-e2e',
7-
test: {
8-
reporters: ['basic'],
9-
testTimeout: 40_000,
10-
globals: true,
11-
alias: tsconfigPathAliases(),
12-
pool: 'threads',
13-
poolOptions: { threads: { singleThread: true } },
14-
cache: {
15-
dir: '../../node_modules/.vitest',
16-
},
17-
environment: 'node',
18-
include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
19-
setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'],
20-
},
4+
export default createE2ETestConfig('plugin-coverage-e2e', {
5+
testTimeout: 40_000,
216
});
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
/// <reference types="vitest" />
2-
import { defineConfig } from 'vitest/config';
3-
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';
2+
import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js';
43

5-
export default defineConfig({
6-
cacheDir: '../../node_modules/.vite/plugin-lighthouse-e2e',
7-
test: {
8-
reporters: ['basic'],
9-
testTimeout: 20_000,
10-
globals: true,
11-
alias: tsconfigPathAliases(),
12-
pool: 'threads',
13-
poolOptions: { threads: { singleThread: true } },
14-
cache: {
15-
dir: '../../node_modules/.vitest',
16-
},
17-
environment: 'node',
18-
include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
19-
setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'],
20-
},
4+
export default createE2ETestConfig('plugin-eslint-e2e', {
5+
testTimeout: 20_000,
216
});
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
/// <reference types="vitest" />
2-
import { defineConfig } from 'vitest/config';
3-
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';
2+
import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js';
43

5-
export default defineConfig({
6-
cacheDir: '../../node_modules/.vite/plugin-js-packages-e2e',
7-
test: {
8-
reporters: ['basic'],
9-
testTimeout: 120_000,
10-
globals: true,
11-
alias: tsconfigPathAliases(),
12-
pool: 'threads',
13-
poolOptions: { threads: { singleThread: true } },
14-
cache: {
15-
dir: '../../node_modules/.vitest',
16-
},
17-
environment: 'node',
18-
include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
19-
setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'],
20-
},
4+
export default createE2ETestConfig('plugin-js-packages-e2e', {
5+
testTimeout: 120_000,
216
});
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
/// <reference types="vitest" />
2-
import { defineConfig } from 'vitest/config';
3-
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';
2+
import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js';
43

5-
export default defineConfig({
6-
cacheDir: '../../node_modules/.vite/plugin-jsdocs-e2e',
7-
test: {
8-
reporters: ['basic'],
9-
testTimeout: 20_000,
10-
globals: true,
11-
alias: tsconfigPathAliases(),
12-
pool: 'threads',
13-
poolOptions: { threads: { singleThread: true } },
14-
cache: {
15-
dir: '../../node_modules/.vitest',
16-
},
17-
environment: 'node',
18-
include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
19-
setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'],
20-
},
4+
export default createE2ETestConfig('plugin-jsdocs-e2e', {
5+
testTimeout: 20_000,
216
});
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
/// <reference types="vitest" />
2-
import { defineConfig } from 'vitest/config';
3-
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';
2+
import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js';
43

5-
export default defineConfig({
6-
cacheDir: '../../node_modules/.vite/plugin-lighthouse-e2e',
7-
test: {
8-
reporters: ['basic'],
9-
testTimeout: 80_000,
10-
globals: true,
11-
alias: tsconfigPathAliases(),
12-
pool: 'threads',
13-
poolOptions: { threads: { singleThread: true } },
14-
cache: {
15-
dir: '../../node_modules/.vitest',
16-
},
17-
environment: 'node',
18-
include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
19-
setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'],
20-
},
4+
export default createE2ETestConfig('plugin-lighthouse-e2e', {
5+
testTimeout: 80_000,
216
});
Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,4 @@
11
/// <reference types="vitest" />
2-
import { defineConfig } from 'vitest/config';
3-
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';
2+
import { createIntTestConfig } from '../../testing/test-setup-config/src/index.js';
43

5-
export default defineConfig({
6-
cacheDir: '../../node_modules/.vite/examples-plugins',
7-
test: {
8-
reporters: ['basic'],
9-
globals: true,
10-
cache: {
11-
dir: '../../node_modules/.vitest',
12-
},
13-
alias: tsconfigPathAliases(),
14-
pool: 'threads',
15-
poolOptions: { threads: { singleThread: true } },
16-
coverage: {
17-
reporter: ['text', 'lcov'],
18-
reportsDirectory: '../../coverage/examples-plugins/int-tests',
19-
exclude: ['**/mocks/**', '**/mock/**', 'code-pushup.config.ts'],
20-
},
21-
environment: 'node',
22-
include: ['src/**/*.int.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
23-
globalSetup: ['../../global-setup.ts'],
24-
setupFiles: [
25-
'../../testing/test-setup/src/lib/git.mock.ts',
26-
'../../testing/test-setup/src/lib/console.mock.ts',
27-
'../../testing/test-setup/src/lib/reset.mocks.ts',
28-
],
29-
},
30-
});
4+
export default createIntTestConfig('examples-plugins');
Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,4 @@
11
/// <reference types="vitest" />
2-
import { defineConfig } from 'vitest/config';
3-
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';
2+
import { createUnitTestConfig } from '../../testing/test-setup-config/src/index.js';
43

5-
export default defineConfig({
6-
cacheDir: '../../node_modules/.vite/examples-plugins',
7-
test: {
8-
reporters: ['basic'],
9-
globals: true,
10-
cache: {
11-
dir: '../../node_modules/.vitest',
12-
},
13-
alias: tsconfigPathAliases(),
14-
pool: 'threads',
15-
poolOptions: { threads: { singleThread: true } },
16-
coverage: {
17-
reporter: ['text', 'lcov'],
18-
reportsDirectory: '../../coverage/examples-plugins/unit-tests',
19-
exclude: ['**/mocks/**', '**/mock/**', 'code-pushup.config.ts'],
20-
},
21-
environment: 'node',
22-
include: ['src/**/*.unit.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
23-
globalSetup: ['../../global-setup.ts'],
24-
setupFiles: [
25-
'../../testing/test-setup/src/lib/fs.mock.ts',
26-
'../../testing/test-setup/src/lib/git.mock.ts',
27-
'../../testing/test-setup/src/lib/console.mock.ts',
28-
'../../testing/test-setup/src/lib/reset.mocks.ts',
29-
],
30-
},
31-
});
4+
export default createUnitTestConfig('examples-plugins');

0 commit comments

Comments
 (0)