mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
[jest] add *_node presets (#126192)
This commit is contained in:
parent
a20e4baa54
commit
1a1a191eb7
18 changed files with 97 additions and 22 deletions
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preset: '@kbn/test',
|
preset: '@kbn/test/jest_node',
|
||||||
rootDir: '../..',
|
rootDir: '../..',
|
||||||
roots: ['<rootDir>/packages/kbn-es'],
|
roots: ['<rootDir>/packages/kbn-es'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preset: '@kbn/test/jest_integration',
|
preset: '@kbn/test/jest_integration_node',
|
||||||
rootDir: '../..',
|
rootDir: '../..',
|
||||||
roots: ['<rootDir>/packages/kbn-es'],
|
roots: ['<rootDir>/packages/kbn-es'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preset: '@kbn/test',
|
preset: '@kbn/test/jest_node',
|
||||||
rootDir: '../..',
|
rootDir: '../..',
|
||||||
roots: ['<rootDir>/packages/kbn-optimizer'],
|
roots: ['<rootDir>/packages/kbn-optimizer'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preset: '@kbn/test/jest_integration',
|
preset: '@kbn/test/jest_integration_node',
|
||||||
rootDir: '../..',
|
rootDir: '../..',
|
||||||
roots: ['<rootDir>/packages/kbn-optimizer'],
|
roots: ['<rootDir>/packages/kbn-optimizer'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preset: '@kbn/test',
|
preset: '@kbn/test/jest_node',
|
||||||
rootDir: '../..',
|
rootDir: '../..',
|
||||||
roots: ['<rootDir>/packages/kbn-plugin-generator'],
|
roots: ['<rootDir>/packages/kbn-plugin-generator'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preset: '@kbn/test/jest_integration',
|
preset: '@kbn/test/jest_integration_node',
|
||||||
rootDir: '../..',
|
rootDir: '../..',
|
||||||
roots: ['<rootDir>/packages/kbn-plugin-generator'],
|
roots: ['<rootDir>/packages/kbn-plugin-generator'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preset: '@kbn/test/jest_integration',
|
preset: '@kbn/test/jest_integration_node',
|
||||||
rootDir: '../..',
|
rootDir: '../..',
|
||||||
roots: ['<rootDir>/packages/kbn-plugin-helpers'],
|
roots: ['<rootDir>/packages/kbn-plugin-helpers'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,6 +30,8 @@ filegroup(
|
||||||
NPM_MODULE_EXTRA_FILES = [
|
NPM_MODULE_EXTRA_FILES = [
|
||||||
"jest-preset.js",
|
"jest-preset.js",
|
||||||
"jest_integration/jest-preset.js",
|
"jest_integration/jest-preset.js",
|
||||||
|
"jest_integration_node/jest-preset.js",
|
||||||
|
"jest_node/jest-preset.js",
|
||||||
"jest.config.js",
|
"jest.config.js",
|
||||||
"README.md",
|
"README.md",
|
||||||
"package.json",
|
"package.json",
|
||||||
|
|
|
@ -66,14 +66,15 @@ module.exports = {
|
||||||
// The paths to modules that run some code to configure or set up the testing environment before each test
|
// The paths to modules that run some code to configure or set up the testing environment before each test
|
||||||
setupFiles: [
|
setupFiles: [
|
||||||
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/babel_polyfill.js',
|
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/babel_polyfill.js',
|
||||||
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/polyfills.js',
|
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/polyfills.jsdom.js',
|
||||||
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/enzyme.js',
|
'<rootDir>/node_modules/@kbn/test/target_node/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
|
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
||||||
setupFilesAfterEnv: [
|
setupFilesAfterEnv: [
|
||||||
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/setup_test.js',
|
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/setup_test.js',
|
||||||
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/mocks.js',
|
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/mocks.moment_timezone.js',
|
||||||
|
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/mocks.eui.js',
|
||||||
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/react_testing_library.js',
|
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/react_testing_library.js',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preset: '@kbn/test',
|
preset: '@kbn/test/jest_node',
|
||||||
rootDir: '../..',
|
rootDir: '../..',
|
||||||
roots: ['<rootDir>/packages/kbn-test'],
|
roots: ['<rootDir>/packages/kbn-test'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preset: '@kbn/test/jest_integration',
|
preset: '@kbn/test/jest_integration_node',
|
||||||
rootDir: '../..',
|
rootDir: '../..',
|
||||||
roots: ['<rootDir>/packages/kbn-test'],
|
roots: ['<rootDir>/packages/kbn-test'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,8 @@ module.exports = {
|
||||||
),
|
),
|
||||||
setupFilesAfterEnv: [
|
setupFilesAfterEnv: [
|
||||||
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/after_env.integration.js',
|
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/after_env.integration.js',
|
||||||
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/mocks.js',
|
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/mocks.moment_timezone.js',
|
||||||
|
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/mocks.eui.js',
|
||||||
],
|
],
|
||||||
reporters: [
|
reporters: [
|
||||||
'default',
|
'default',
|
||||||
|
|
46
packages/kbn-test/jest_integration_node/jest-preset.js
Normal file
46
packages/kbn-test/jest_integration_node/jest-preset.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const preset = require('../jest-preset');
|
||||||
|
|
||||||
|
/** @typedef {import("@jest/types").Config.InitialOptions} JestConfig */
|
||||||
|
/** @type {JestConfig} */
|
||||||
|
module.exports = {
|
||||||
|
...preset,
|
||||||
|
testMatch: ['**/integration_tests**/*.test.{js,mjs,ts,tsx}'],
|
||||||
|
testPathIgnorePatterns: preset.testPathIgnorePatterns.filter(
|
||||||
|
(pattern) => !pattern.includes('integration_tests')
|
||||||
|
),
|
||||||
|
setupFilesAfterEnv: [
|
||||||
|
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/after_env.integration.js',
|
||||||
|
'<rootDir>/node_modules/@kbn/test/target_node/jest/setup/mocks.moment_timezone.js',
|
||||||
|
],
|
||||||
|
reporters: [
|
||||||
|
'default',
|
||||||
|
[
|
||||||
|
'@kbn/test/target_node/jest/junit_reporter',
|
||||||
|
{
|
||||||
|
rootDirectory: '.',
|
||||||
|
reportName: 'Jest Integration Tests',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'@kbn/test/target_node/jest/ci_stats_jest_reporter',
|
||||||
|
{
|
||||||
|
testGroupType: 'Jest Integration Tests',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
coverageReporters: !!process.env.CI
|
||||||
|
? [['json', { file: 'jest-integration.json' }]]
|
||||||
|
: ['html', 'text'],
|
||||||
|
|
||||||
|
testEnvironment: 'node',
|
||||||
|
snapshotSerializers: [],
|
||||||
|
setupFiles: ['<rootDir>/node_modules/@kbn/test/target_node/jest/setup/babel_polyfill.js'],
|
||||||
|
};
|
16
packages/kbn-test/jest_node/jest-preset.js
Normal file
16
packages/kbn-test/jest_node/jest-preset.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const preset = require('../jest-preset');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
...preset,
|
||||||
|
testEnvironment: 'node',
|
||||||
|
snapshotSerializers: [],
|
||||||
|
setupFiles: ['<rootDir>/node_modules/@kbn/test/target_node/jest/setup/babel_polyfill.js'],
|
||||||
|
};
|
18
packages/kbn-test/src/jest/setup/mocks.eui.js
Normal file
18
packages/kbn-test/src/jest/setup/mocks.eui.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* eslint-env jest */
|
||||||
|
|
||||||
|
jest.mock('@elastic/eui/lib/services/react', () => {
|
||||||
|
// `enqueueStateChange` is an EUI method to batch queued functions that trigger React `setState` calls.
|
||||||
|
// This is for performance, but when used in certain Jest scernarios it can be nondeterministic.
|
||||||
|
// Jest tests are never concerned about the state prior to batch completion, so we bypass batching entirely.
|
||||||
|
return {
|
||||||
|
enqueueStateChange: (fn) => fn(),
|
||||||
|
};
|
||||||
|
});
|
|
@ -33,12 +33,3 @@ jest.mock('moment-timezone', () => {
|
||||||
moment.tz.setDefault('America/New_York');
|
moment.tz.setDefault('America/New_York');
|
||||||
return moment;
|
return moment;
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.mock('@elastic/eui/lib/services/react', () => {
|
|
||||||
// `enqueueStateChange` is an EUI method to batch queued functions that trigger React `setState` calls.
|
|
||||||
// This is for performance, but when used in certain Jest scernarios it can be nondeterministic.
|
|
||||||
// Jest tests are never concerned about the state prior to batch completion, so we bypass batching entirely.
|
|
||||||
return {
|
|
||||||
enqueueStateChange: (fn) => fn(),
|
|
||||||
};
|
|
||||||
});
|
|
|
@ -39,7 +39,7 @@ export const IGNORE_FILE_GLOBS = [
|
||||||
'vars/*',
|
'vars/*',
|
||||||
'.ci/pipeline-library/**/*',
|
'.ci/pipeline-library/**/*',
|
||||||
'packages/kbn-test/jest-preset.js',
|
'packages/kbn-test/jest-preset.js',
|
||||||
'packages/kbn-test/jest_integration/jest-preset.js',
|
'packages/kbn-test/*/jest-preset.js',
|
||||||
'test/package/Vagrantfile',
|
'test/package/Vagrantfile',
|
||||||
'**/test/**/fixtures/**/*',
|
'**/test/**/fixtures/**/*',
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue