Skip to content

Commit

Permalink
use TS for agent mock
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Dec 6, 2021
1 parent 5ed187b commit df6e05d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/kbn-test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ TYPES_DEPS = [
"//packages/kbn-i18n-react:npm_module_types",
"//packages/kbn-utils",
"@npm//@elastic/elasticsearch",
"@npm//elastic-apm-node",
"@npm//del",
"@npm//form-data",
"@npm//jest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* Side Public License, v 1.
*/

import type { Agent } from 'elastic-apm-node';

/**
* `elastic-apm-node` patches the runtime at import time
* causing memory leak with jest module sandbox, so it
* needs to be mocked for tests
*/

/* eslint-disable no-undef */
const agent = {
const agent: jest.Mocked<Agent> = {
start: jest.fn().mockImplementation(() => agent),
isStarted: jest.fn().mockReturnValue(false),
getServiceName: jest.fn().mockReturnValue('mock-service'),
Expand Down Expand Up @@ -59,4 +59,5 @@ const agent = {
},
};

module.exports = agent;
// eslint-disable-next-line import/no-default-export
export default agent;

0 comments on commit df6e05d

Please sign in to comment.