vitest.config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. const { defineConfig } = require('vitest/config')
  2. const COVERAGE_ENABLED = process.env.COVERAGE_UNIT_TESTS === 'true'
  3. let reporterOptions = {}
  4. if (process.env.CI && process.env.JUNIT_ROOT_SUITE_NAME) {
  5. reporterOptions = {
  6. maxWorkers: '50%',
  7. reporters: [
  8. 'default',
  9. [
  10. 'junit',
  11. {
  12. classnameTemplate: `${process.env.JUNIT_ROOT_SUITE_NAME}.{filename}`,
  13. },
  14. ],
  15. ],
  16. outputFile: 'data/reports/junit-vitest.xml',
  17. }
  18. }
  19. module.exports = defineConfig({
  20. test: {
  21. setupFiles: ['./test/unit/bootstrap.mjs'],
  22. globals: true,
  23. isolate: false,
  24. passWithNoTests: true, // in case there are no tests from one project or other in a module
  25. projects: [
  26. {
  27. extends: true,
  28. test: {
  29. name: 'Parallel',
  30. include: [
  31. 'modules/*/test/unit/**/*.test.mjs',
  32. 'test/unit/src/**/*.test.mjs',
  33. ],
  34. sequence: {
  35. groupOrder: 2,
  36. },
  37. exclude: ['**/*.sequential.test.mjs'],
  38. fileParallelism: true,
  39. },
  40. },
  41. {
  42. extends: true,
  43. test: {
  44. name: 'Sequential',
  45. sequence: {
  46. groupOrder: 1,
  47. },
  48. include: [
  49. 'modules/*/test/unit/**/*.sequential.test.mjs',
  50. 'test/unit/src/**/*.sequential.test.mjs',
  51. ],
  52. fileParallelism: false,
  53. },
  54. },
  55. ],
  56. ...reporterOptions,
  57. hookTimeout: COVERAGE_ENABLED ? 20_000 : 10_000,
  58. coverage: {
  59. enabled: COVERAGE_ENABLED,
  60. // Add 'sequential' / 'parallel' to the folder
  61. reportsDirectory: `data/coverage/esm-unit-${(process.env.JUNIT_ROOT_SUITE_NAME || 'all').split(' ').pop()}`,
  62. include: [
  63. 'app.mjs',
  64. 'app/**/*.{js,mjs}',
  65. 'modules/*/index.mjs',
  66. 'modules/*/app/src/**/*.{js,mjs}',
  67. ],
  68. exclude: ['app/src/Features/Metadata/packageMapping.mjs'],
  69. provider: 'istanbul',
  70. reporters: ['console-details', 'clover'],
  71. all: true,
  72. },
  73. },
  74. })