kibana/packages/kbn-test/jest-preset.js
Xavier Mouligneau 4fa3dc46cb
[RAC] T-Grid is moving to a new home (#100265)
* wip

* First pass at standalone and embedded redux stores and usage

* wip

* First pass at standalone and embedded redux stores and usage

* wip

* clean up

* wip

* refact(NA): remove extra pkg_npm target and add specific target folders on @kbn/i18n

* cleanup

* - fixes type errors in tests

* WIP remove use_manage_timeline

* wip add query + selector

* finishing integrating timeline manage context from redux

* integrating t-grid in security solution

* fix RowRender type

* WIP begin to move components from package to plugin

* integration of t-grid inside of security solution

* wip to make redux work

* little trick to make  it render

* - fixes a few type errors

* better integration betwen tgrid and security solutions

* bringing back tsconfig on timeline

* wip integration t-grid in observability

* fix types

* fix type in security solutions

* add type to import + trie dto get the bundle size as small as possible

* fix type in integration test

* fix type in integration test

* - fix tests

* clean up to use technical fields

* - fixes unit tests

* - mocks the `useDateFormat` function of the `useKibana` service to fix unit tests

* fix t-grid settings vs create timeline + fix inspect button

* fix last suites test

* Update unit tests, snapshots and lint

* Fix bad merge

* fix plugin export

* Fix some failing tests

* fix unit tets in timelines plugins

* fix latest test

* fix i18n

* free obs from t-grid

* Fix timeline functional plugin types

* fix store provider

* Update failing defaultHeader test

* Fix i18n usage in security solution

* Fix remaining i18n errors in timelines plugin

* Dedupe common shared types

* move drag and drop utils in package to avoid duplication

* More shared type cleanup

* add feature flag

* review I

* fix merge  with master

* fix i18n translation

* More type deduping

* Use @kbn/common-utils, fix remaining types

* fix types

* fix tests

* missing type

* fix cypress tests

Co-authored-by: Kevin Qualters <kevin.qualters@elastic.co>
Co-authored-by: Tiago Costa <tiagoffcc@hotmail.com>
Co-authored-by: Andrew Goldstein <andrew.goldstein@elastic.co>
2021-06-22 18:56:33 -04:00

114 lines
5.2 KiB
JavaScript

/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html
const { resolve } = require('path');
module.exports = {
// The directory where Jest should output its coverage files
coverageDirectory: '<rootDir>/target/kibana-coverage/jest',
// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: ['/node_modules/', '.*\\.d\\.ts'],
// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: !!process.env.CODE_COVERAGE
? [['json', { file: 'jest.json' }]]
: ['html', 'text'],
// An array of file extensions your modules use
moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'],
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
'@elastic/eui/lib/(.*)?': '<rootDir>/node_modules/@elastic/eui/test-env/$1',
'@elastic/eui$': '<rootDir>/node_modules/@elastic/eui/test-env',
'\\.module.(css|scss)$': '<rootDir>/packages/kbn-test/target/jest/mocks/css_module_mock.js',
'\\.(css|less|scss)$': '<rootDir>/packages/kbn-test/target/jest/mocks/style_mock.js',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/packages/kbn-test/target/jest/mocks/file_mock.js',
'\\.ace\\.worker.js$': '<rootDir>/packages/kbn-test/target/jest/mocks/worker_module_mock.js',
'\\.editor\\.worker.js$': '<rootDir>/packages/kbn-test/target/jest/mocks/worker_module_mock.js',
'^(!!)?file-loader!': '<rootDir>/packages/kbn-test/target/jest/mocks/file_mock.js',
'^src/core/(.*)': '<rootDir>/src/core/$1',
'^src/plugins/(.*)': '<rootDir>/src/plugins/$1',
},
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
modulePathIgnorePatterns: ['__fixtures__/', 'target/'],
// Use this configuration option to add custom reporters to Jest
reporters: ['default', resolve(__dirname, './target/jest/junit_reporter')],
// The paths to modules that run some code to configure or set up the testing environment before each test
setupFiles: [
'<rootDir>/packages/kbn-test/target/jest/setup/babel_polyfill.js',
'<rootDir>/packages/kbn-test/target/jest/setup/polyfills.js',
'<rootDir>/packages/kbn-test/target/jest/setup/enzyme.js',
],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: [
'<rootDir>/packages/kbn-test/target/jest/setup/setup_test.js',
'<rootDir>/packages/kbn-test/target/jest/setup/mocks.js',
'<rootDir>/packages/kbn-test/target/jest/setup/react_testing_library.js',
],
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
snapshotSerializers: [
'<rootDir>/src/plugins/kibana_react/public/util/test_helpers/react_mount_serializer.ts',
'<rootDir>/node_modules/enzyme-to-json/serializer',
],
// The test environment that will be used for testing
testEnvironment: 'jest-environment-jsdom',
// The glob patterns Jest uses to detect test files
testMatch: ['**/*.test.{js,mjs,ts,tsx}'],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: [
'<rootDir>/packages/kbn-ui-framework/dist/',
'<rootDir>/packages/kbn-pm/dist/',
`integration_tests/`,
],
// This option allows use of a custom test runner
testRunner: 'jest-circus/runner',
// A map from regular expressions to paths to transformers
transform: {
'^.+\\.(js|tsx?)$': '<rootDir>/packages/kbn-test/target/jest/babel_transform.js',
'^.+\\.txt?$': 'jest-raw-loader',
'^.+\\.html?$': 'jest-raw-loader',
},
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
transformIgnorePatterns: [
// ignore all node_modules except monaco-editor and react-monaco-editor which requires babel transforms to handle dynamic import()
// since ESM modules are not natively supported in Jest yet (https://github.com/facebook/jest/issues/4842)
'[/\\\\]node_modules(?![\\/\\\\](monaco-editor|react-monaco-editor|d3-interpolate|d3-color))[/\\\\].+\\.js$',
'packages/kbn-pm/dist/index.js',
],
// An array of regexp pattern strings that are matched against all source file paths, matched files to include/exclude for code coverage
collectCoverageFrom: [
'**/*.{js,mjs,jsx,ts,tsx}',
'!**/{__test__,__snapshots__,__examples__,*mock*,tests,test_helpers,integration_tests,types}/**/*',
'!**/*mock*.ts',
'!**/*.test.ts',
'!**/*.d.ts',
'!**/index.{js,ts}',
],
// A custom resolver to preserve symlinks by default
resolver: '<rootDir>/packages/kbn-test/target/jest/setup/preserve_symlinks_resolver.js',
};