jest.config.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright 2018-2022 Elyra Authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* global module, require, __dirname */
  17. const func = require('@jupyterlab/testutils/lib/jest-config');
  18. const upstream = func('jupyterlab_go_to_definition', __dirname);
  19. const reuseFromUpstream = [
  20. 'setupFilesAfterEnv',
  21. 'setupFiles',
  22. 'moduleFileExtensions'
  23. ];
  24. const esModules = [
  25. 'lib0',
  26. 'y\\-protocols',
  27. 'y\\-websocket',
  28. 'yjs',
  29. '(@jupyterlab/.*)/'
  30. ].join('|');
  31. const local = {
  32. globals: { 'ts-jest': { tsConfig: 'tsconfig.json' } },
  33. // eslint-disable-next-line no-useless-escape
  34. testRegex: `.*\.spec\.tsx?$`,
  35. transform: {
  36. '\\.(ts|tsx)?$': 'ts-jest',
  37. '\\.(js|jsx)?$': '../../testutils/transform.js',
  38. '\\.svg$': 'jest-raw-loader'
  39. },
  40. transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`],
  41. moduleNameMapper: {
  42. '\\.(css|less|sass|scss)$': 'identity-obj-proxy',
  43. '\\.(gif|ttf|eot)$': '@jupyterlab/testutils/lib/jest-file-mock.js'
  44. }
  45. };
  46. for (const option of reuseFromUpstream) {
  47. local[option] = upstream[option];
  48. }
  49. local['setupFilesAfterEnv'] = ['../../testutils/jest.setup.js'];
  50. module.exports = local;