jest.config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. const ENABLE_COVERAGE = !!process.env.CI;
  3. const requiresPrettierInternals = [
  4. "tests_integration/__tests__/util-shared.js",
  5. "tests_integration/__tests__/help-options.js"
  6. ];
  7. const semver = require("semver");
  8. const isOldNode = semver.parse(process.version).major <= 4;
  9. module.exports = {
  10. setupFiles: ["<rootDir>/tests_config/run_spec.js"],
  11. snapshotSerializers: ["<rootDir>/tests_config/raw-serializer.js"],
  12. testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
  13. testPathIgnorePatterns: ["tests/new_react", "tests/more_react"].concat(
  14. isOldNode ? requiresPrettierInternals : []
  15. ),
  16. collectCoverage: ENABLE_COVERAGE,
  17. collectCoverageFrom: ["src/**/*.js", "index.js", "!<rootDir>/node_modules/"],
  18. coveragePathIgnorePatterns: [
  19. "<rootDir>/standalone.js",
  20. "<rootDir>/src/doc/doc-debug.js",
  21. "<rootDir>/src/main/massage-ast.js"
  22. ],
  23. moduleNameMapper: {
  24. // Jest wires `fs` to `graceful-fs`, which causes a memory leak when
  25. // `graceful-fs` does `require('fs')`.
  26. // Ref: https://github.com/facebook/jest/issues/2179#issuecomment-355231418
  27. // If this is removed, see also scripts/build/build.js.
  28. "graceful-fs": "<rootDir>/tests_config/fs.js",
  29. "prettier/local": "<rootDir>/tests_config/require_prettier.js"
  30. },
  31. transform: {}
  32. };