Skip to content

Commit

Permalink
replace casting with custom Window interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlemeshko committed Nov 17, 2020
1 parent d371911 commit 38163d2
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions test/common/fixtures/plugins/coverage/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

import { Plugin } from 'kibana/server';

interface WindowWithCoverage extends Window {
__coverage__: any;
flushCoverageToLog: any;
declare global {
interface Window {
__coverage__: any;
flushCoverageToLog: any;
}
}

export class CodeCoverageReportingPlugin implements Plugin {
Expand All @@ -30,18 +32,12 @@ export class CodeCoverageReportingPlugin implements Plugin {
public start() {}

public setup() {
(window as WindowWithCoverage & typeof globalThis).flushCoverageToLog = function () {
if ((window as WindowWithCoverage & typeof globalThis).__coverage__) {
window.flushCoverageToLog = function () {
if (window.__coverage__) {
// eslint-disable-next-line no-console
console.log(
'coveragejson:' +
btoa(JSON.stringify((window as WindowWithCoverage & typeof globalThis).__coverage__))
);
console.log('coveragejson:' + btoa(JSON.stringify(window.__coverage__)));
}
};
window.addEventListener(
'beforeunload',
(window as WindowWithCoverage & typeof globalThis).flushCoverageToLog
);
window.addEventListener('beforeunload', window.flushCoverageToLog);
}
}

0 comments on commit 38163d2

Please sign in to comment.