2020-10-20 23:41:47 +08:00
|
|
|
// We set this specifically for 2 reasons.
|
|
|
|
// 1. It makes sense for both CI tests and local tests to behave the same so issues are found earlier
|
|
|
|
// 2. Any wrong timezone handling could be hidden if we use UTC/GMT local time (which would happen in CI).
|
2023-04-17 23:19:44 +08:00
|
|
|
process.env.TZ = 'Pacific/Easter'; // UTC-06:00 or UTC-05:00 depending on daylight savings
|
2020-09-17 14:59:20 +08:00
|
|
|
|
2023-12-20 21:14:57 +08:00
|
|
|
const esModules = [
|
2024-01-25 18:52:49 +08:00
|
|
|
'@glideapps/glide-data-grid',
|
2023-12-20 21:14:57 +08:00
|
|
|
'ol',
|
|
|
|
'd3',
|
|
|
|
'd3-color',
|
|
|
|
'd3-interpolate',
|
|
|
|
'delaunator',
|
|
|
|
'internmap',
|
|
|
|
'robust-predicates',
|
|
|
|
'leven',
|
2024-01-12 22:05:46 +08:00
|
|
|
'nanoid',
|
2024-02-06 03:46:35 +08:00
|
|
|
'monaco-promql',
|
2023-12-20 21:14:57 +08:00
|
|
|
].join('|');
|
2023-01-26 20:02:22 +08:00
|
|
|
|
2017-10-22 13:03:26 +08:00
|
|
|
module.exports = {
|
2017-11-17 23:18:30 +08:00
|
|
|
verbose: false,
|
2021-12-04 01:09:25 +08:00
|
|
|
testEnvironment: 'jsdom',
|
2020-02-14 04:37:24 +08:00
|
|
|
transform: {
|
2022-11-24 22:00:41 +08:00
|
|
|
'^.+\\.(ts|tsx|js|jsx)$': [require.resolve('ts-jest'), { isolatedModules: true }],
|
2017-10-22 13:03:26 +08:00
|
|
|
},
|
2021-07-16 03:00:19 +08:00
|
|
|
transformIgnorePatterns: [
|
2023-01-26 20:02:22 +08:00
|
|
|
`/node_modules/(?!${esModules})`, // exclude es modules to prevent TS complaining
|
2021-07-16 03:00:19 +08:00
|
|
|
],
|
2024-01-29 22:27:35 +08:00
|
|
|
moduleDirectories: ['public', 'node_modules'],
|
2022-02-16 21:15:31 +08:00
|
|
|
roots: ['<rootDir>/public/app', '<rootDir>/public/test', '<rootDir>/packages'],
|
2020-02-14 04:37:24 +08:00
|
|
|
testRegex: '(\\.|/)(test)\\.(jsx?|tsx?)$',
|
|
|
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
|
2023-05-15 16:15:26 +08:00
|
|
|
setupFiles: ['jest-canvas-mock', './public/test/jest-setup.ts'],
|
2021-05-19 18:40:10 +08:00
|
|
|
testTimeout: 30000,
|
2022-05-30 21:14:34 +08:00
|
|
|
resolver: `<rootDir>/public/test/jest-resolver.js`,
|
2020-08-20 21:21:42 +08:00
|
|
|
setupFilesAfterEnv: ['./public/test/setupTests.ts'],
|
2021-04-23 15:06:19 +08:00
|
|
|
globals: {
|
|
|
|
__webpack_public_path__: '', // empty string
|
|
|
|
},
|
2020-05-04 21:05:31 +08:00
|
|
|
moduleNameMapper: {
|
|
|
|
'\\.svg': '<rootDir>/public/test/mocks/svg.ts',
|
2020-06-30 01:58:47 +08:00
|
|
|
'\\.css': '<rootDir>/public/test/mocks/style.ts',
|
2023-10-24 19:16:32 +08:00
|
|
|
'react-inlinesvg': '<rootDir>/public/test/mocks/react-inlinesvg.tsx',
|
2020-09-03 14:54:46 +08:00
|
|
|
'monaco-editor/esm/vs/editor/editor.api': '<rootDir>/public/test/mocks/monaco.ts',
|
2023-06-05 16:51:36 +08:00
|
|
|
// near-membrane-dom won't work in a nodejs environment.
|
|
|
|
'@locker/near-membrane-dom': '<rootDir>/public/test/mocks/nearMembraneDom.ts',
|
2023-07-05 22:24:48 +08:00
|
|
|
'^@grafana/schema/dist/esm/(.*)$': '<rootDir>/packages/grafana-schema/src/$1',
|
2023-08-31 21:45:44 +08:00
|
|
|
// prevent systemjs amd extra from breaking tests.
|
|
|
|
'systemjs/dist/extras/amd': '<rootDir>/public/test/mocks/systemjsAMDExtra.ts',
|
2020-05-04 21:05:31 +08:00
|
|
|
},
|
2022-12-27 19:06:06 +08:00
|
|
|
// Log the test results with dynamic Loki tags. Drone CI only
|
|
|
|
reporters: ['default', ['<rootDir>/public/test/log-reporter.js', { enable: process.env.DRONE === 'true' }]],
|
2017-10-22 13:03:26 +08:00
|
|
|
};
|