diff --git a/webapp/platform/components/babel.config.js b/webapp/platform/components/babel.config.js index 641b2cf2e8..06f9099d35 100644 --- a/webapp/platform/components/babel.config.js +++ b/webapp/platform/components/babel.config.js @@ -11,6 +11,13 @@ const config = { safari: 12, }, modules: false, + corejs: { + version: "3.26", + proposals: true, + }, + debug: false, + shippedProposals: true, + useBuiltIns: 'usage', }], ['@babel/preset-react', { useBuiltIns: true, @@ -39,4 +46,12 @@ const config = { ], }; +config.env = { + test: { + presets: config.presets, + plugins: config.plugins, + }, +}; +config.env.test.presets[0][1].modules = 'auto'; + module.exports = config; diff --git a/webapp/platform/components/jest.config.js b/webapp/platform/components/jest.config.js new file mode 100644 index 0000000000..8c1d80cb89 --- /dev/null +++ b/webapp/platform/components/jest.config.js @@ -0,0 +1,21 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +/** @type {import('jest').Config} */ + +const config = { + moduleDirectories: ['src', 'node_modules'], + testEnvironment: 'jsdom', + testPathIgnorePatterns: ['/node_modules/', '/.rollup.cache/', '/dist/'], + clearMocks: true, + moduleNameMapper: { + '^@mattermost/(components)$': '/../platform/$1/src', + '^@mattermost/(client)$': '/../platform/$1/src', + '^@mattermost/(types)/(.*)$': '/../platform/$1/src/$2', + '^.+\\.(css|scss)$': 'identity-obj-proxy', + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + setupFilesAfterEnv: ['/src/setupTests.ts'], +}; + +module.exports = config; diff --git a/webapp/platform/components/package.json b/webapp/platform/components/package.json index 0675cc5a53..8324322d63 100644 --- a/webapp/platform/components/package.json +++ b/webapp/platform/components/package.json @@ -7,6 +7,7 @@ "scripts": { "build": "rollup -c", "run": "rollup -c --watch", + "test": "cross-env TZ=Etc/UTC jest", "clean": "rm -rf dist node_modules tsconfig.tsbuildinfo .rollup.cache" }, "devDependencies": { diff --git a/webapp/platform/components/src/legacy_generic_modal/__snapshots__/legacy_generic_modal.test.tsx.snap b/webapp/platform/components/src/legacy_generic_modal/__snapshots__/legacy_generic_modal.test.tsx.snap new file mode 100644 index 0000000000..c43b2c8d65 --- /dev/null +++ b/webapp/platform/components/src/legacy_generic_modal/__snapshots__/legacy_generic_modal.test.tsx.snap @@ -0,0 +1,143 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`LegacyGenericModal should match snapshot for base case 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +