jest-preset.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * The path's declared below are relative. Specifically, they are relative to the location of this file after
  3. * compilation of the Stencil compiler has completed. See `scripts/bundles/testing` for the location of this file
  4. * following compilation.
  5. */
  6. const path = require('path');
  7. const testingDir = __dirname;
  8. const rootDir = path.join(testingDir, '..');
  9. const internalDir = path.join(rootDir, 'internal');
  10. // NOTE: if you change this, also change compiler/transpile.ts
  11. const moduleExtensions = ['ts', 'tsx', 'js', 'mjs', 'jsx'];
  12. const moduleExtensionRegexp = '(' + moduleExtensions.join('|') + ')';
  13. module.exports = {
  14. moduleFileExtensions: [...moduleExtensions, 'json', 'd.ts'],
  15. moduleNameMapper: {
  16. '^@stencil/core/cli$': path.join(rootDir, 'cli', 'index.js'),
  17. '^@stencil/core/compiler$': path.join(rootDir, 'compiler', 'stencil.js'),
  18. '^@stencil/core/internal$': path.join(internalDir, 'testing', 'index.js'),
  19. '^@stencil/core/internal/app-data$': path.join(internalDir, 'app-data', 'index.cjs'),
  20. '^@stencil/core/internal/app-globals$': path.join(internalDir, 'app-globals', 'index.js'),
  21. '^@stencil/core/internal/testing$': path.join(internalDir, 'testing', 'index.js'),
  22. '^@stencil/core/mock-doc$': path.join(rootDir, 'mock-doc', 'index.cjs'),
  23. '^@stencil/core/sys$': path.join(rootDir, 'sys', 'node', 'index.js'),
  24. '^@stencil/core/testing$': path.join(testingDir, 'index.js'),
  25. '^@stencil/core$': path.join(internalDir, 'testing', 'index.js'),
  26. },
  27. setupFilesAfterEnv: [path.join(testingDir, 'jest-setuptestframework.js')],
  28. testEnvironment: path.join(testingDir, 'jest-environment.js'),
  29. testPathIgnorePatterns: ['/.cache', '/.stencil', '/.vscode', '/dist', '/node_modules', '/www'],
  30. testRegex: '(/__tests__/.*|\\.?(test|spec))\\.' + moduleExtensionRegexp + '$',
  31. transform: {
  32. '^.+\\.(ts|tsx|jsx|css)$': path.join(testingDir, 'jest-preprocessor.js'),
  33. },
  34. watchPathIgnorePatterns: ['^.+\\.d\\.ts$'],
  35. };