mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[code coverage] adding plugin to flush coverage data (#83447)
* [test/common] adding code coverage plugin * start plugin only when CODE_COVERAGE flag is set * build coverage plugin * replace casting with custom Window interface
This commit is contained in:
parent
484437f66d
commit
27125bce30
6 changed files with 79 additions and 0 deletions
|
@ -61,6 +61,10 @@ export default function () {
|
|||
`--plugin-path=${path.join(__dirname, 'fixtures', 'plugins', 'newsfeed')}`,
|
||||
`--newsfeed.service.urlRoot=${servers.kibana.protocol}://${servers.kibana.hostname}:${servers.kibana.port}`,
|
||||
`--newsfeed.service.pathTemplate=/api/_newsfeed-FTS-external-service-simulators/kibana/v{VERSION}.json`,
|
||||
// code coverage reporting plugin
|
||||
...(!!process.env.CODE_COVERAGE
|
||||
? [`--plugin-path=${path.join(__dirname, 'fixtures', 'plugins', 'coverage')}`]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
services,
|
||||
|
|
6
test/common/fixtures/plugins/coverage/kibana.json
Normal file
6
test/common/fixtures/plugins/coverage/kibana.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"id": "coverage-fixtures",
|
||||
"version": "kibana",
|
||||
"server": false,
|
||||
"ui": true
|
||||
}
|
24
test/common/fixtures/plugins/coverage/public/index.ts
Normal file
24
test/common/fixtures/plugins/coverage/public/index.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { CodeCoverageReportingPlugin } from './plugin';
|
||||
|
||||
export function plugin() {
|
||||
return new CodeCoverageReportingPlugin();
|
||||
}
|
43
test/common/fixtures/plugins/coverage/public/plugin.ts
Normal file
43
test/common/fixtures/plugins/coverage/public/plugin.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { Plugin } from 'kibana/server';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__coverage__: any;
|
||||
flushCoverageToLog: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class CodeCoverageReportingPlugin implements Plugin {
|
||||
constructor() {}
|
||||
|
||||
public start() {}
|
||||
|
||||
public setup() {
|
||||
window.flushCoverageToLog = function () {
|
||||
if (window.__coverage__) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('coveragejson:' + btoa(JSON.stringify(window.__coverage__)));
|
||||
}
|
||||
};
|
||||
window.addEventListener('beforeunload', window.flushCoverageToLog);
|
||||
}
|
||||
}
|
|
@ -7,5 +7,6 @@ node scripts/build_kibana_platform_plugins \
|
|||
--oss \
|
||||
--scan-dir "$KIBANA_DIR/test/plugin_functional/plugins" \
|
||||
--scan-dir "$KIBANA_DIR/test/interpreter_functional/plugins" \
|
||||
--scan-dir "$KIBANA_DIR/test/common/fixtures/plugins" \
|
||||
--workers 6 \
|
||||
--verbose
|
||||
|
|
|
@ -5,6 +5,7 @@ source src/dev/ci_setup/setup_env.sh
|
|||
echo " -> building kibana platform plugins"
|
||||
node scripts/build_kibana_platform_plugins \
|
||||
--scan-dir "$KIBANA_DIR/test/plugin_functional/plugins" \
|
||||
--scan-dir "$KIBANA_DIR/test/common/fixtures/plugins" \
|
||||
--scan-dir "$XPACK_DIR/test/plugin_functional/plugins" \
|
||||
--scan-dir "$XPACK_DIR/test/functional_with_es_ssl/fixtures/plugins" \
|
||||
--scan-dir "$XPACK_DIR/test/alerting_api_integration/plugins" \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue