diff --git a/x-pack/solutions/security/plugins/security_solution/jest/babel-transformer.js b/x-pack/solutions/security/plugins/security_solution/jest/babel-transformer.js new file mode 100644 index 0000000000000..d72b0ff2f1521 --- /dev/null +++ b/x-pack/solutions/security/plugins/security_solution/jest/babel-transformer.js @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +// eslint-disable-next-line import/no-extraneous-dependencies +const babelJest = require('babel-jest'); + +// eslint-disable-next-line import/no-extraneous-dependencies +const rootTransformerConfig = require('@kbn/test/src/jest/transforms/babel/transformer_config'); + +module.exports = babelJest.default.createTransformer({ + ...rootTransformerConfig, + presets: [ + ...rootTransformerConfig.presets, + [ + require.resolve('@emotion/babel-preset-css-prop'), + { + labelFormat: '[filename]--[local]', + }, + ], + ], +}); diff --git a/x-pack/solutions/security/plugins/security_solution/public/common/mock/test_providers.tsx b/x-pack/solutions/security/plugins/security_solution/public/common/mock/test_providers.tsx index c4525faf3b316..7414e3c1c2de3 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/common/mock/test_providers.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/common/mock/test_providers.tsx @@ -17,6 +17,8 @@ import { ThemeProvider } from 'styled-components'; import type { Capabilities } from '@kbn/core/public'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; +import { coreMock } from '@kbn/core/public/mocks'; import type { Action } from '@kbn/ui-actions-plugin/public'; import { CellActionsProvider } from '@kbn/cell-actions'; import { TestProvider as ExpandableFlyoutTestProvider } from '@kbn/expandable-flyout/src/test/provider'; @@ -74,31 +76,33 @@ export const TestProvidersComponent = ({ }); return ( - - - - - ({ eui: euiDarkVars, darkMode: true })}> - - - - - - Promise.resolve(cellActions)} - > - {children} - - - - - - - - - - - + + + + + + ({ eui: euiDarkVars, darkMode: true })}> + + + + + + Promise.resolve(cellActions)} + > + {children} + + + + + + + + + + + + ); }; diff --git a/x-pack/solutions/security/plugins/security_solution/public/overview/jest.config.js b/x-pack/solutions/security/plugins/security_solution/public/overview/jest.config.js index b7348132cd6af..cf25241bf13f3 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/overview/jest.config.js +++ b/x-pack/solutions/security/plugins/security_solution/public/overview/jest.config.js @@ -5,6 +5,9 @@ * 2.0. */ +// eslint-disable-next-line import/no-extraneous-dependencies +const rootConfig = require('@kbn/test/jest-preset'); + module.exports = { preset: '@kbn/test', rootDir: '../../../../../../..', @@ -16,4 +19,9 @@ module.exports = { '/x-pack/solutions/security/plugins/security_solution/public/overview/**/*.{ts,tsx}', ], moduleNameMapper: require('../../server/__mocks__/module_name_map'), + transform: { + ...rootConfig.transform, + '^.+\\.(js|tsx?)$': + '/x-pack/solutions/security/plugins/security_solution/jest/babel-transformer.js', + }, };