jest-config.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. import path = require('path');
  2. module.exports = function(name: string, baseDir: string) {
  3. return {
  4. preset: 'ts-jest/presets/js-with-babel',
  5. moduleNameMapper: {
  6. '\\.(css|less|sass|scss)$': 'identity-obj-proxy',
  7. '\\.(gif|ttf|eot)$': '@jupyterlab/testutils/lib/jest-file-mock.js'
  8. },
  9. transform: {
  10. '\\.svg$': 'jest-raw-loader'
  11. },
  12. setupFiles: ['@jupyterlab/testutils/lib/jest-shim.js'],
  13. testPathIgnorePatterns: ['/dev_mode/', '/lib/', '/node_modules/'],
  14. moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
  15. rootDir: path.resolve(path.join(baseDir, '..', '..')),
  16. reporters: ['default', 'jest-junit'],
  17. collectCoverageFrom: [
  18. `packages/${name}/src/**.{ts,tsx}`,
  19. `!packages/${name}/src/*.d.ts`
  20. ],
  21. testTimeout: 20000,
  22. coverageReporters: ['json', 'lcov', 'text', 'html'],
  23. coverageDirectory: path.join(baseDir, 'coverage'),
  24. testRegex: `tests\/test-${name}\/src\/.*\.spec\.tsx?$`,
  25. globals: {
  26. 'ts-jest': {
  27. tsConfig: `./tsconfig.json`
  28. }
  29. }
  30. };
  31. };