2021-11-23 16:17:48 -05:00
|
|
|
const os = require('os');
|
|
|
|
|
2022-11-04 17:22:07 +01:00
|
|
|
// TODO Revisit this test later, when we have a windows machine @valentinpalkovic
|
|
|
|
const skipOnWindows = [
|
|
|
|
'lib/core-server/src/utils/stories-json.test.ts',
|
|
|
|
'lib/core-server/src/utils/StoryIndexGenerator.test.ts',
|
|
|
|
'lib/cli/src/helpers.test.ts',
|
|
|
|
'lib/core-server/src/utils/__tests__/server-statics.test.ts',
|
|
|
|
'lib/core-common/src/utils/__tests__/template.test.ts',
|
|
|
|
'addons/storyshots/storyshots-core/src/frameworks/configure.test.ts',
|
|
|
|
'lib/core-common/src/utils/__tests__/interpret-files.test.ts',
|
|
|
|
'lib/builder-manager/src/utils/files.test.ts',
|
|
|
|
'lib/cli/src/helpers.test.ts',
|
|
|
|
'lib/core-server/src/utils/__tests__/server-statics.test.ts',
|
|
|
|
'lib/core-common/src/utils/__tests__/template.test.ts',
|
|
|
|
'addons/storyshots/storyshots-core/src/frameworks/configure.test.ts',
|
|
|
|
'lib/core-common/src/utils/__tests__/interpret-files.test.ts',
|
|
|
|
'lib/builder-manager/src/utils/files.test.ts',
|
|
|
|
];
|
|
|
|
|
2017-05-18 17:57:07 +01:00
|
|
|
module.exports = {
|
2017-12-23 21:12:27 +01:00
|
|
|
cacheDirectory: '.cache/jest',
|
2017-05-18 17:57:07 +01:00
|
|
|
clearMocks: true,
|
|
|
|
moduleNameMapper: {
|
2019-05-06 13:55:27 +02:00
|
|
|
// non-js files
|
2020-10-01 08:37:48 +02:00
|
|
|
'\\.(jpg|jpeg|png|apng|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
2017-06-05 00:58:23 +02:00
|
|
|
'<rootDir>/__mocks__/fileMock.js',
|
2019-03-05 12:08:27 +07:00
|
|
|
'\\.(css|scss|stylesheet)$': '<rootDir>/__mocks__/styleMock.js',
|
2017-11-13 23:06:01 -05:00
|
|
|
'\\.(md)$': '<rootDir>/__mocks__/htmlMock.js',
|
2019-05-06 13:55:27 +02:00
|
|
|
|
|
|
|
// core-js v2 to v3 mapping
|
|
|
|
'core-js/modules/es6.(.*)': 'core-js/modules/es.$1',
|
|
|
|
'core-js/modules/es7.(.*)': 'core-js/modules/esnext.$1',
|
|
|
|
'core-js/library/fn/(.*)': `core-js/features/$1`,
|
|
|
|
'core-js/es5/(.*)': `core-js/es/$1`,
|
|
|
|
'core-js/es6/(.*)': `core-js/es/$1`,
|
|
|
|
'core-js/es7/reflect': `core-js/proposals/reflect-metadata`,
|
|
|
|
'core-js/es7/(.*)': `core-js/proposals/$1`,
|
|
|
|
'core-js/object$/': `core-js/es/object`,
|
|
|
|
'core-js/object/(.*)': `core-js/es/object/$1`,
|
|
|
|
'babel-runtime/core-js/(.*)': `core-js/es/$1`,
|
|
|
|
// 'babel-runtime/core-js/object/assign'
|
|
|
|
'core-js/library/fn/object/assign': 'core-js/es/object/assign',
|
2017-05-18 17:57:07 +01:00
|
|
|
},
|
2022-10-18 22:04:10 +02:00
|
|
|
projects: ['<rootDir>'],
|
2022-10-12 15:30:02 +11:00
|
|
|
roots: ['<rootDir>/addons', '<rootDir>/frameworks', '<rootDir>/lib', '<rootDir>/renderers'],
|
2017-12-26 16:32:18 +02:00
|
|
|
transform: {
|
2019-09-05 09:00:32 +02:00
|
|
|
'^.+\\.stories\\.[jt]sx?$': '@storybook/addon-storyshots/injectFileName',
|
2022-07-21 16:30:28 +02:00
|
|
|
'^.+\\.[jt]sx?$': '<rootDir>/../scripts/utils/jest-transform-js.js',
|
2019-10-08 02:39:42 +02:00
|
|
|
'^.+\\.mdx$': '@storybook/addon-docs/jest-transform-mdx',
|
2017-12-26 16:32:18 +02:00
|
|
|
},
|
2022-10-19 18:25:19 +08:00
|
|
|
transformIgnorePatterns: [
|
|
|
|
'/node_modules/(?!(lit-html|@mdx-js)).+\\.js',
|
|
|
|
'/node_modules/(?!).+\\.js',
|
|
|
|
],
|
2019-04-04 19:51:28 +02:00
|
|
|
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
|
|
testPathIgnorePatterns: [
|
2022-05-27 15:37:49 +02:00
|
|
|
'/storybook-static/',
|
2019-04-04 19:51:28 +02:00
|
|
|
'/node_modules/',
|
|
|
|
'/dist/',
|
2020-10-30 15:54:56 +01:00
|
|
|
'/prebuilt/',
|
2022-10-18 22:04:10 +02:00
|
|
|
'/template/',
|
2019-04-04 19:51:28 +02:00
|
|
|
'addon-jest.test.js',
|
2022-05-12 01:35:46 +08:00
|
|
|
'/frameworks/angular/*',
|
2022-05-11 16:57:17 +02:00
|
|
|
'/examples/*/src/*.*',
|
|
|
|
'/examples/*/src/*/*.*',
|
|
|
|
'/examples/*/src/*/*/*.*',
|
2022-10-19 10:23:48 +02:00
|
|
|
// TODO: Can not get svelte-jester to work, but also not necessary for this test, as it is run by tsc/svelte-check.
|
|
|
|
'/renderers/svelte/src/public-types.test.ts',
|
2022-10-24 16:51:20 +02:00
|
|
|
'/renderers/vue/src/public-types.test.ts',
|
2022-10-24 16:51:54 +02:00
|
|
|
'/renderers/vue3/src/public-types.test.ts',
|
2022-11-04 17:22:07 +01:00
|
|
|
...(process.platform === 'win32' ? skipOnWindows : []),
|
2019-04-04 19:51:28 +02:00
|
|
|
],
|
2018-12-19 00:03:19 +01:00
|
|
|
collectCoverage: false,
|
2017-05-23 20:56:54 +02:00
|
|
|
collectCoverageFrom: [
|
2022-10-18 22:04:10 +02:00
|
|
|
'frameworks/*/src/**/*.{js,jsx,ts,tsx}',
|
|
|
|
'lib/*/src/**/*.{js,jsx,ts,tsx}',
|
|
|
|
'renderers/*/src/**/*.{js,jsx,ts,tsx}',
|
|
|
|
'addons/*/src/**/*.{js,jsx,ts,tsx}',
|
2019-03-18 22:27:32 +01:00
|
|
|
],
|
|
|
|
coveragePathIgnorePatterns: [
|
|
|
|
'/node_modules/',
|
|
|
|
'/cli/test/',
|
|
|
|
'/dist/',
|
2020-10-30 15:54:56 +01:00
|
|
|
'/prebuilt/',
|
2019-03-18 22:27:32 +01:00
|
|
|
'/generators/',
|
2022-10-18 22:04:10 +02:00
|
|
|
'/template/',
|
2019-03-18 22:27:32 +01:00
|
|
|
'/dll/',
|
|
|
|
'/__mocks__ /',
|
2022-03-21 12:51:59 +01:00
|
|
|
'/__mockdata__/',
|
|
|
|
'/__mocks-ng-workspace__/',
|
2019-07-09 01:09:47 +02:00
|
|
|
'/__testfixtures__/',
|
2020-06-14 03:28:35 +03:00
|
|
|
'^.*\\.stories\\.[jt]sx?$',
|
2022-05-02 18:56:15 +08:00
|
|
|
'typings.d.ts$',
|
2017-05-23 20:56:54 +02:00
|
|
|
],
|
2019-06-20 11:59:37 +08:00
|
|
|
globals: {
|
2019-07-01 16:18:20 +08:00
|
|
|
PREVIEW_URL: undefined,
|
2021-11-23 16:17:48 -05:00
|
|
|
SNAPSHOT_OS: os.platform() === 'win32' ? 'windows' : 'posix',
|
2019-06-20 11:59:37 +08:00
|
|
|
},
|
2022-03-06 22:07:16 +01:00
|
|
|
snapshotSerializers: [
|
|
|
|
'@emotion/jest/serializer',
|
|
|
|
'enzyme-to-json/serializer',
|
|
|
|
'jest-serializer-html',
|
|
|
|
],
|
2017-05-18 17:57:07 +01:00
|
|
|
coverageDirectory: 'coverage',
|
2022-07-21 23:25:23 +02:00
|
|
|
setupFilesAfterEnv: ['./jest.init.ts'],
|
2019-03-18 22:27:32 +01:00
|
|
|
coverageReporters: ['lcov'],
|
2019-03-18 21:28:00 +01:00
|
|
|
testEnvironment: 'jest-environment-jsdom-thirteen',
|
2017-09-28 14:25:49 +02:00
|
|
|
setupFiles: ['raf/polyfill'],
|
2017-12-23 00:57:53 +01:00
|
|
|
testURL: 'http://localhost',
|
2022-10-18 22:04:10 +02:00
|
|
|
modulePathIgnorePatterns: [
|
|
|
|
//
|
|
|
|
'/dist/.*/__mocks__/',
|
|
|
|
'/storybook-static/',
|
|
|
|
'/template/',
|
|
|
|
],
|
2018-12-16 12:12:26 +02:00
|
|
|
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
|
2019-03-18 22:27:32 +01:00
|
|
|
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
|
2022-04-04 08:42:14 +08:00
|
|
|
reporters: ['default', 'jest-junit'],
|
2017-05-18 17:57:07 +01:00
|
|
|
};
|