-
Notifications
You must be signed in to change notification settings - Fork 16
refactor: common vitest configurations #1107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
504126d
feat(): create common vitest config setup
f15c31f
refactor(): wip use common vitest on few files
597923d
refactor(): change coverage reports directory
11337cf
refactor(): simplify vitest factory and split abstract logic
c31e21a
docs(): update new tools readme
e29df01
test(): add unit tests for new tools
6925534
refactor(): fix circular dependency by creating new internal library
7288d8e
fix: path resolution
db99af2
fix: path resolution #2
44a0891
fix: path resolution #3
0eaaa5a
fix: path resolution #4
0bf21ec
fix: path resolution #5
c0d6e77
refactor(testing): improve vitest config factory and test coverage
32ce2cb
refactor(testing): standardize Vitest configuration and improve setup…
5f32d0d
refactor(testing): consolidate global setup logic and remove redundan…
abf7f5d
refactor(testing): enhance documentation and Vitest configuration setup
3efd81f
refactor(testing): use config factory for vitest config files
cef39d3
refactor(testing): replace logger with console.warn in test folder te…
38bc0bb
chore(testing): add logger mock to integration test setup files and u…
fa74e58
refactor(testing): include logger mock configs and adjust related tests
b792eeb
refactor(testing): add guard check for console info in mock file
9f41bb2
refactor(testing): remove redundant comment
2772f2b
refactor(testing): remove Vitest reference comments from configuratio…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,5 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vitest/config'; | ||
| import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
| import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default defineConfig({ | ||
| cacheDir: '../../node_modules/.vite/ci-e2e', | ||
| test: { | ||
| reporters: ['basic'], | ||
| testTimeout: 60_000, | ||
| globals: true, | ||
| alias: tsconfigPathAliases(), | ||
| pool: 'threads', | ||
| poolOptions: { threads: { singleThread: true } }, | ||
| cache: { | ||
| dir: '../../node_modules/.vitest', | ||
| }, | ||
| environment: 'node', | ||
| include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
| globalSetup: './global-setup.ts', | ||
| setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'], | ||
| }, | ||
| export default createE2ETestConfig('ci-e2e', { | ||
| testTimeout: 60_000, | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,5 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vitest/config'; | ||
| import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
| import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default defineConfig({ | ||
| cacheDir: '../../node_modules/.vite/cli-e2e', | ||
| test: { | ||
| reporters: ['basic'], | ||
| testTimeout: 20_000, | ||
| globals: true, | ||
| alias: tsconfigPathAliases(), | ||
| pool: 'threads', | ||
| poolOptions: { threads: { singleThread: true } }, | ||
| cache: { | ||
| dir: '../../node_modules/.vitest', | ||
| }, | ||
| environment: 'node', | ||
| include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
| setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'], | ||
| }, | ||
| export default createE2ETestConfig('cli-e2e', { | ||
| testTimeout: 20_000, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,5 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vitest/config'; | ||
| import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
| import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default defineConfig({ | ||
| cacheDir: '../../node_modules/.vite/create-cli-e2e', | ||
| test: { | ||
| reporters: ['basic'], | ||
| testTimeout: 20_000, | ||
| hookTimeout: 20_000, | ||
| globals: true, | ||
| alias: tsconfigPathAliases(), | ||
| pool: 'threads', | ||
| poolOptions: { threads: { singleThread: true } }, | ||
| cache: { | ||
| dir: '../../node_modules/.vitest', | ||
| }, | ||
| environment: 'node', | ||
| include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
| setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'], | ||
| }, | ||
| export default createE2ETestConfig('create-cli-e2e', { | ||
| testTimeout: 20_000, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,5 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vitest/config'; | ||
| import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
| import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default defineConfig({ | ||
| cacheDir: '../../node_modules/.vite/nx-plugin-e2e', | ||
| test: { | ||
| reporters: ['basic'], | ||
| testTimeout: 80_000, | ||
| globals: true, | ||
| alias: tsconfigPathAliases(), | ||
| pool: 'threads', | ||
| poolOptions: { threads: { singleThread: true } }, | ||
| cache: { | ||
| dir: '../../node_modules/.vitest', | ||
| }, | ||
| environment: 'node', | ||
| include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
| setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'], | ||
| }, | ||
| export default createE2ETestConfig('nx-plugin-e2e', { | ||
| testTimeout: 80_000, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,5 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vitest/config'; | ||
| import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
| import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default defineConfig({ | ||
| cacheDir: '../../node_modules/.vite/plugin-coverage-e2e', | ||
| test: { | ||
| reporters: ['basic'], | ||
| testTimeout: 40_000, | ||
| globals: true, | ||
| alias: tsconfigPathAliases(), | ||
| pool: 'threads', | ||
| poolOptions: { threads: { singleThread: true } }, | ||
| cache: { | ||
| dir: '../../node_modules/.vitest', | ||
| }, | ||
| environment: 'node', | ||
| include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
| setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'], | ||
| }, | ||
| export default createE2ETestConfig('plugin-coverage-e2e', { | ||
| testTimeout: 40_000, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,5 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vitest/config'; | ||
| import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
| import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default defineConfig({ | ||
| cacheDir: '../../node_modules/.vite/plugin-lighthouse-e2e', | ||
| test: { | ||
| reporters: ['basic'], | ||
| testTimeout: 20_000, | ||
| globals: true, | ||
| alias: tsconfigPathAliases(), | ||
| pool: 'threads', | ||
| poolOptions: { threads: { singleThread: true } }, | ||
| cache: { | ||
| dir: '../../node_modules/.vitest', | ||
| }, | ||
| environment: 'node', | ||
| include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
| setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'], | ||
| }, | ||
| export default createE2ETestConfig('plugin-eslint-e2e', { | ||
| testTimeout: 20_000, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,5 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vitest/config'; | ||
| import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
| import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default defineConfig({ | ||
| cacheDir: '../../node_modules/.vite/plugin-js-packages-e2e', | ||
| test: { | ||
| reporters: ['basic'], | ||
| testTimeout: 120_000, | ||
| globals: true, | ||
| alias: tsconfigPathAliases(), | ||
| pool: 'threads', | ||
| poolOptions: { threads: { singleThread: true } }, | ||
| cache: { | ||
| dir: '../../node_modules/.vitest', | ||
| }, | ||
| environment: 'node', | ||
| include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
| setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'], | ||
| }, | ||
| export default createE2ETestConfig('plugin-js-packages-e2e', { | ||
| testTimeout: 120_000, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,5 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vitest/config'; | ||
| import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
| import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default defineConfig({ | ||
| cacheDir: '../../node_modules/.vite/plugin-jsdocs-e2e', | ||
| test: { | ||
| reporters: ['basic'], | ||
| testTimeout: 20_000, | ||
| globals: true, | ||
| alias: tsconfigPathAliases(), | ||
| pool: 'threads', | ||
| poolOptions: { threads: { singleThread: true } }, | ||
| cache: { | ||
| dir: '../../node_modules/.vitest', | ||
| }, | ||
| environment: 'node', | ||
| include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
| setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'], | ||
| }, | ||
| export default createE2ETestConfig('plugin-jsdocs-e2e', { | ||
| testTimeout: 20_000, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,5 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vitest/config'; | ||
| import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
| import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default defineConfig({ | ||
| cacheDir: '../../node_modules/.vite/plugin-lighthouse-e2e', | ||
| test: { | ||
| reporters: ['basic'], | ||
| testTimeout: 80_000, | ||
| globals: true, | ||
| alias: tsconfigPathAliases(), | ||
| pool: 'threads', | ||
| poolOptions: { threads: { singleThread: true } }, | ||
| cache: { | ||
| dir: '../../node_modules/.vitest', | ||
| }, | ||
| environment: 'node', | ||
| include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
| setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'], | ||
| }, | ||
| export default createE2ETestConfig('plugin-lighthouse-e2e', { | ||
| testTimeout: 80_000, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,5 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vitest/config'; | ||
| import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
| import { createE2ETestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default defineConfig({ | ||
| cacheDir: '../../node_modules/.vite/plugin-typescript-e2e', | ||
| test: { | ||
| reporters: ['basic'], | ||
| testTimeout: 20_000, | ||
| globals: true, | ||
| alias: tsconfigPathAliases(), | ||
| pool: 'threads', | ||
| poolOptions: { threads: { singleThread: true } }, | ||
| coverage: { | ||
| reporter: ['text', 'lcov'], | ||
| reportsDirectory: '../../coverage/plugin-typescript-e2e/e2e-tests', | ||
| exclude: ['mocks/**', '**/types.ts'], | ||
| }, | ||
| cache: { | ||
| dir: '../../node_modules/.vitest', | ||
| }, | ||
| environment: 'node', | ||
| include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
| setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'], | ||
| }, | ||
| export default createE2ETestConfig('plugin-typescript-e2e', { | ||
| testTimeout: 20_000, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,3 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vitest/config'; | ||
| import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
| import { createIntTestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default defineConfig({ | ||
| cacheDir: '../../node_modules/.vite/examples-plugins', | ||
| test: { | ||
| reporters: ['basic'], | ||
| globals: true, | ||
| cache: { | ||
| dir: '../../node_modules/.vitest', | ||
| }, | ||
| alias: tsconfigPathAliases(), | ||
| pool: 'threads', | ||
| poolOptions: { threads: { singleThread: true } }, | ||
| coverage: { | ||
| reporter: ['text', 'lcov'], | ||
| reportsDirectory: '../../coverage/examples-plugins/int-tests', | ||
| exclude: ['**/mocks/**', '**/mock/**', 'code-pushup.config.ts'], | ||
| }, | ||
| environment: 'node', | ||
| include: ['src/**/*.int.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
| globalSetup: ['../../global-setup.ts'], | ||
| setupFiles: [ | ||
| '../../testing/test-setup/src/lib/git.mock.ts', | ||
| '../../testing/test-setup/src/lib/console.mock.ts', | ||
| '../../testing/test-setup/src/lib/reset.mocks.ts', | ||
| ], | ||
| }, | ||
| }); | ||
| export default createIntTestConfig('examples-plugins'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,3 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vitest/config'; | ||
| import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
| import { createUnitTestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default defineConfig({ | ||
| cacheDir: '../../node_modules/.vite/examples-plugins', | ||
| test: { | ||
| reporters: ['basic'], | ||
| globals: true, | ||
| cache: { | ||
| dir: '../../node_modules/.vitest', | ||
| }, | ||
| alias: tsconfigPathAliases(), | ||
| pool: 'threads', | ||
| poolOptions: { threads: { singleThread: true } }, | ||
| coverage: { | ||
| reporter: ['text', 'lcov'], | ||
| reportsDirectory: '../../coverage/examples-plugins/unit-tests', | ||
| exclude: ['**/mocks/**', '**/mock/**', 'code-pushup.config.ts'], | ||
| }, | ||
| environment: 'node', | ||
| include: ['src/**/*.unit.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
| globalSetup: ['../../global-setup.ts'], | ||
| setupFiles: [ | ||
| '../../testing/test-setup/src/lib/fs.mock.ts', | ||
| '../../testing/test-setup/src/lib/git.mock.ts', | ||
| '../../testing/test-setup/src/lib/console.mock.ts', | ||
| '../../testing/test-setup/src/lib/reset.mocks.ts', | ||
| ], | ||
| }, | ||
| }); | ||
| export default createUnitTestConfig('examples-plugins'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,18 @@ | ||
| export async function setup() { | ||
| /* eslint-disable functional/immutable-data */ | ||
|
|
||
| const originalCI = process.env['CI']; | ||
|
|
||
| export function setup() { | ||
| process.env.TZ = 'UTC'; | ||
|
|
||
| // package is expected to run in CI environment | ||
| process.env['CI'] = 'true'; | ||
| } | ||
|
|
||
| export function teardown() { | ||
| if (originalCI === undefined) { | ||
| delete process.env['CI']; | ||
| } else { | ||
| process.env['CI'] = originalCI; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.