jest.config.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. const { pathsToModuleNameMapper } = require("ts-jest");
  2. const tsconfig = require("../../tsconfig.base.json");
  3. /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
  4. module.exports = {
  5. bail: true,
  6. roots: ["<rootDir>/src"],
  7. preset: "../../jest.preset.js",
  8. setupFilesAfterEnv: ["./jest.setup.js"],
  9. testEnvironment: "jsdom",
  10. verbose: false,
  11. collectCoverageFrom: [
  12. "src/**/*.{js,jsx,ts,tsx}",
  13. // @todo they actually don't work, so we had to add `istanbul ignore` directive to some files
  14. "!**/__mocks__/**",
  15. "!**/*.d.ts",
  16. "!**/node_modules/**",
  17. "!**/examples/**",
  18. // it breaks internal coverage counters because of dynamic imports
  19. "!src/**/SplitChannel.ts",
  20. ],
  21. coverageDirectory: "../../coverage",
  22. coverageReporters: ["json", "lcov", "text"],
  23. coverageThreshold: {
  24. global: {
  25. branches: 1,
  26. functions: 1,
  27. lines: 1,
  28. statements: 1,
  29. },
  30. },
  31. transform: {
  32. "^.+\\.[tj]sx?$": [
  33. "babel-jest",
  34. {
  35. presets: [
  36. [
  37. "@babel/preset-react",
  38. {
  39. runtime: "automatic",
  40. },
  41. ],
  42. "@babel/preset-typescript",
  43. [
  44. "@babel/preset-env",
  45. {
  46. targets: {
  47. browsers: ["last 2 Chrome versions"],
  48. node: "current",
  49. },
  50. },
  51. ],
  52. ],
  53. plugins: [
  54. ["babel-plugin-import", { libraryName: "antd", style: false }],
  55. "@babel/plugin-proposal-class-properties",
  56. "@babel/plugin-proposal-private-methods",
  57. "@babel/plugin-proposal-optional-chaining",
  58. "@babel/plugin-proposal-nullish-coalescing-operator",
  59. ],
  60. },
  61. ],
  62. },
  63. moduleFileExtensions: ["js", "ts", "jsx", "tsx"],
  64. moduleDirectories: ["node_modules"],
  65. moduleNameMapper: {
  66. "^konva": "konva/konva",
  67. "^keymaster": "identity-obj-proxy",
  68. "^react-konva-utils": "identity-obj-proxy",
  69. "\\.(s[ac]ss|css|svg|png|jpe?g)$": "identity-obj-proxy",
  70. "^@adobe/css-tools$": "<rootDir>/../../__mocks__/@adobe/css-tools.js",
  71. "^@humansignal/ui": "<rootDir>/../ui/src/index.ts",
  72. ...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, {
  73. prefix: "<rootDir>/../../",
  74. }),
  75. },
  76. testPathIgnorePatterns: ["/node_modules/", "/e2e/"],
  77. transformIgnorePatterns: ["node_modules/?!(nanoid|konva|@adobe)"],
  78. };