config.mjs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
  2. const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
  3. const defaultCoverageExcludes = [
  4. "coverage/**",
  5. "dist/**",
  6. "packages/*/test{,s}/**",
  7. "**/*.d.ts",
  8. "cypress/**",
  9. "test{,s}/**",
  10. "test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
  11. "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
  12. "**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
  13. "**/__tests__/**",
  14. "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.{js,cjs,mjs,ts}",
  15. "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
  16. ];
  17. const coverageConfigDefaults = {
  18. provider: "c8",
  19. enabled: false,
  20. clean: true,
  21. cleanOnRerun: false,
  22. reportsDirectory: "./coverage",
  23. excludeNodeModules: true,
  24. exclude: defaultCoverageExcludes,
  25. reporter: ["text", "html", "clover", "json"],
  26. allowExternal: false,
  27. extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
  28. };
  29. const fakeTimersDefaults = {
  30. loopLimit: 1e4,
  31. shouldClearNativeTimers: true,
  32. toFake: [
  33. "setTimeout",
  34. "clearTimeout",
  35. "setInterval",
  36. "clearInterval",
  37. "setImmediate",
  38. "clearImmediate",
  39. "Date"
  40. ]
  41. };
  42. const config = {
  43. allowOnly: !process.env.CI,
  44. watch: !process.env.CI,
  45. globals: false,
  46. environment: "node",
  47. threads: true,
  48. clearMocks: false,
  49. restoreMocks: false,
  50. mockReset: false,
  51. include: defaultInclude,
  52. exclude: defaultExclude,
  53. testTimeout: 5e3,
  54. hookTimeout: 1e4,
  55. teardownTimeout: 1e3,
  56. isolate: true,
  57. watchExclude: ["**/node_modules/**", "**/dist/**"],
  58. forceRerunTriggers: [
  59. "**/package.json/**",
  60. "**/vitest.config.*/**",
  61. "**/vite.config.*/**"
  62. ],
  63. update: false,
  64. reporters: [],
  65. silent: false,
  66. api: false,
  67. ui: false,
  68. uiBase: "/__vitest__/",
  69. open: true,
  70. css: {
  71. include: []
  72. },
  73. coverage: coverageConfigDefaults,
  74. fakeTimers: fakeTimersDefaults,
  75. maxConcurrency: 5,
  76. dangerouslyIgnoreUnhandledErrors: false
  77. };
  78. const configDefaults = Object.freeze(config);
  79. function defineConfig(config) {
  80. return config;
  81. }
  82. export { configDefaults, defaultExclude, defaultInclude, defineConfig };