Skip to content

Commit

Permalink
reorganize vitest config files
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-takei committed Sep 19, 2024
1 parent 8061cac commit 15960a5
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 79 deletions.
8 changes: 4 additions & 4 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"prelint:swagger2openapi": "yarn openapi:v3",
"test": "run-p test:*",
"test:jest": "cross-env NODE_ENV=test TS_NODE_PROJECT=test/integration/tsconfig.json jest",
"test:vitest": "run-p vitest:run vitest:run:integ vitest:run:components",
"test:vitest": "run-p vitest:run:*",
"jest:run": "cross-env NODE_ENV=test TS_NODE_PROJECT=test/integration/tsconfig.json jest --passWithNoTests -- ",
"reg:run": "reg-suit run",
"vitest:run": "vitest run config src --coverage",
"vitest:run:integ": "vitest run -c vitest.config.integ.ts src --coverage",
"vitest:run:components": "vitest run -c vitest.config.components.ts src --coverage",
"vitest:run:unit": "vitest run src --project=app-unit --coverage",
"vitest:run:integ": "vitest run src --project=app-integration --coverage",
"vitest:run:components": "vitest run src --project=app-components --coverage",
"previtest:run:integ": "vitest run -c test-with-vite/download-mongo-binary/vitest.config.ts test-with-vite/download-mongo-binary",
"//// misc": "",
"console": "yarn repl",
Expand Down
29 changes: 15 additions & 14 deletions apps/app/test-with-vite/download-mongo-binary/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { defineConfig, mergeConfig } from 'vitest/config';
import tsconfigPaths from 'vite-tsconfig-paths';
import { defineConfig } from 'vitest/config';

import configShared from '../../vitest.config';

export default mergeConfig(
configShared,
defineConfig({
test: {
hookTimeout: 60000, // increased for downloading MongoDB binary file
setupFiles: [
'./test-with-vite/setup/mongoms.ts',
],
},
}),
);
export default defineConfig({
plugins: [
tsconfigPaths(),
],
test: {
clearMocks: true,
globals: true,
hookTimeout: 60000, // increased for downloading MongoDB binary file
setupFiles: [
'./test-with-vite/setup/mongoms.ts',
],
},
});
19 changes: 0 additions & 19 deletions apps/app/vitest.config.components.ts

This file was deleted.

23 changes: 0 additions & 23 deletions apps/app/vitest.config.integ.ts

This file was deleted.

19 changes: 0 additions & 19 deletions apps/app/vitest.config.ts

This file was deleted.

73 changes: 73 additions & 0 deletions apps/app/vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
import { defineProject, defineWorkspace, mergeConfig } from 'vitest/config';

const projectShared = defineProject({
plugins: [
tsconfigPaths(),
],
test: {
clearMocks: true,
globals: true,
},
});

export default defineWorkspace([

// unit test
mergeConfig(
projectShared,
{
test: {
name: 'app-unit',
environment: 'node',
include: ['**/*.spec.{ts,js}'],
exclude: ['**/test/**'],
coverage: {
reportsDirectory: './coverage/unit',
},
},
},
),

// integration test
mergeConfig(
projectShared,
{
test: {
name: 'app-integration',
environment: 'node',
include: ['**/*.integ.ts'],
exclude: ['**/test/**'],
setupFiles: [
'./test-with-vite/setup/mongoms.ts',
],
coverage: {
reportsDirectory: './coverage/integ',
exclude: [
'**/*{.,-}integ.ts',
],
},
},
},
),

// component test
mergeConfig(
projectShared,
{
plugins: [react()],
test: {
name: 'app-components',
environment: 'happy-dom',
include: [
'**/*.spec.{tsx,jsx}',
],
exclude: ['**/test/**'],
coverage: {
reportsDirectory: './coverage/components',
},
},
},
),
]);
2 changes: 2 additions & 0 deletions vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default [
'apps/*/vitest.config.ts',
'apps/*/vitest.workspace.ts',
'packages/*/vitest.config.ts',
'packages/*/vitest.workspace.ts',
];

0 comments on commit 15960a5

Please sign in to comment.