Skip to content

Commit

Permalink
Combines Jest unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
  • Loading branch information
Tyler Smalley committed Dec 21, 2020
1 parent 27b3a36 commit 9b39e9f
Show file tree
Hide file tree
Showing 20 changed files with 35 additions and 128 deletions.
10 changes: 0 additions & 10 deletions .ci/teamcity/oss/jest.sh

This file was deleted.

10 changes: 0 additions & 10 deletions .ci/teamcity/oss/jest_integration.sh

This file was deleted.

4 changes: 2 additions & 2 deletions .ci/teamcity/default/jest.sh → .ci/teamcity/tests/jest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

source "$(dirname "${0}")/../util.sh"

export JOB=kibana-default-jest
export JOB=kibana-jest

checks-reporter-with-killswitch "Jest Unit Tests" \
node scripts/jest x-pack --ci --verbose --maxWorkers=5
ode scripts/jest --ci --verbose --maxWorkers=10 --coverage --coverageReporters json
10 changes: 10 additions & 0 deletions .ci/teamcity/tests/jest_integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -euo pipefail

source "$(dirname "${0}")/../util.sh"

export JOB=kibana-jest-integration

checks-reporter-with-killswitch "Jest Integration Tests" \
node --expose-gc scripts/jest_integration --logHeapUsage --ci --verbose --coverage --coverageReporters json
2 changes: 1 addition & 1 deletion .teamcity/src/builds/test/AllTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ object AllTests : BuildType({
description = "All Non-Functional Tests"
type = Type.COMPOSITE

dependsOn(QuickTests, Jest, XPackJest, JestIntegration, OssApiServerIntegration)
dependsOn(QuickTests, Jest, JestIntegration, OssApiServerIntegration)
})
2 changes: 1 addition & 1 deletion .teamcity/src/builds/test/Jest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object Jest : BuildType({
kibanaAgent(8)

steps {
runbld("Jest Unit", "./.ci/teamcity/oss/jest.sh")
runbld("Jest Unit", "./.ci/teamcity/tests/jest.sh")
}

addTestSettings()
Expand Down
2 changes: 1 addition & 1 deletion .teamcity/src/builds/test/JestIntegration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object JestIntegration : BuildType({
description = "Executes Jest Integration Tests"

steps {
runbld("Jest Integration", "./.ci/teamcity/oss/jest_integration.sh")
runbld("Jest Integration", "./.ci/teamcity/tests/jest_integration.sh")
}

addTestSettings()
Expand Down
19 changes: 0 additions & 19 deletions .teamcity/src/builds/test/XPackJest.kt

This file was deleted.

1 change: 0 additions & 1 deletion .teamcity/src/projects/Kibana.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ fun Kibana(config: KibanaConfiguration = KibanaConfiguration()) : Project {
name = "Jest"

buildType(Jest)
buildType(XPackJest)
buildType(JestIntegration)
}

Expand Down
1 change: 1 addition & 0 deletions jest.config.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ module.exports = {
],
],
setupFilesAfterEnv: ['<rootDir>/packages/kbn-test/target/jest/setup/after_env.integration.js'],
coverageDirectory: '<rootDir>/target/jest-coverage/jest_integration',
};
10 changes: 9 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,13 @@

module.exports = {
rootDir: '.',
projects: [...require('./jest.config.oss').projects, ...require('./x-pack/jest.config').projects],
projects: [
'<rootDir>/packages/*/jest.config.js',
'<rootDir>/src/*/jest.config.js',
'<rootDir>/src/legacy/*/jest.config.js',
'<rootDir>/src/plugins/*/jest.config.js',
'<rootDir>/test/*/jest.config.js',
...require('./x-pack/jest.config').projects,
],
reporters: ['default', '<rootDir>/packages/kbn-test/target/jest/junit_reporter'],
};
30 changes: 0 additions & 30 deletions jest.config.oss.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/kbn-test/jest-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
coveragePathIgnorePatterns: ['/node_modules/', '.*\\.d\\.ts'],

// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: !!process.env.CODE_COVERAGE ? ['json'] : ['html', 'text'],
coverageReporters: ['html', 'text'],

// An array of file extensions your modules use
moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'],
Expand Down
24 changes: 6 additions & 18 deletions test/scripts/jenkins_unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

source test/scripts/jenkins_test_setup.sh

rename_coverage_file() {
test -f target/kibana-coverage/jest/coverage-final.json \
&& mv target/kibana-coverage/jest/coverage-final.json \
target/kibana-coverage/jest/$1-coverage-final.json
}

if [[ -z "$CODE_COVERAGE" ]] ; then
# Lint
./test/scripts/lint/eslint.sh
Expand All @@ -34,18 +28,12 @@ if [[ -z "$CODE_COVERAGE" ]] ; then
./test/scripts/checks/test_projects.sh
./test/scripts/checks/test_hardening.sh
else
echo " -> Running jest tests with coverage"
node scripts/jest --ci --verbose --coverage --config jest.config.oss.js || true;
rename_coverage_file "oss"
echo ""
echo ""
echo " -> Running jest integration tests with coverage"
node --max-old-space-size=8192 scripts/jest_integration --ci --verbose --coverage || true;
rename_coverage_file "oss-integration"
echo ""
echo ""
echo " -> Build runtime for canvas"
node ./x-pack/plugins/canvas/scripts/shareable_runtime

./test/scripts/test/jest_unit.sh
./test/scripts/test/jest_integration.sh

echo " -> Running mocha tests with coverage"
./test/scripts/checks/mocha_coverage.sh
echo ""
echo ""
fi
23 changes: 0 additions & 23 deletions test/scripts/jenkins_xpack.sh

This file was deleted.

2 changes: 1 addition & 1 deletion test/scripts/test/jest_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
source src/dev/ci_setup/setup_env.sh

checks-reporter-with-killswitch "Jest Integration Tests" \
node scripts/jest_integration --ci --verbose
node --expose-gc scripts/jest_integration --logHeapUsage --ci --verbose --coverage --coverageReporters json
2 changes: 1 addition & 1 deletion test/scripts/test/jest_unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
source src/dev/ci_setup/setup_env.sh

checks-reporter-with-killswitch "Jest Unit Tests" \
node scripts/jest --config jest.config.oss.js --ci --verbose --maxWorkers=5
node scripts/jest --ci --verbose --maxWorkers=10 --coverage --coverageReporters json
6 changes: 0 additions & 6 deletions test/scripts/test/xpack_jest_unit.sh

This file was deleted.

2 changes: 1 addition & 1 deletion test/scripts/test/xpack_karma.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
source src/dev/ci_setup/setup_env.sh

cd x-pack
checks-reporter-with-killswitch "X-Pack Karma Tests" yarn test:karma
checks-reporter-with-killswitch "X-Pack Karma Tests" yarn test:karma
1 change: 0 additions & 1 deletion vars/tasks.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def test() {

kibanaPipeline.scriptTask('Jest Unit Tests', 'test/scripts/test/jest_unit.sh'),
kibanaPipeline.scriptTask('API Integration Tests', 'test/scripts/test/api_integration.sh'),
kibanaPipeline.scriptTask('X-Pack Jest Unit Tests', 'test/scripts/test/xpack_jest_unit.sh'),
])
}

Expand Down

0 comments on commit 9b39e9f

Please sign in to comment.