-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mock
elastic-apm-node
in @kbn/test
jest preset
- Loading branch information
1 parent
f3aa761
commit 616eba4
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* `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 = { | ||
start: jest.fn().mockImplementation(() => agent), | ||
isStarted: jest.fn().mockReturnValue(false), | ||
getServiceName: jest.fn().mockReturnValue('mock-service'), | ||
setFramework: jest.fn(), | ||
addPatch: jest.fn(), | ||
removePatch: jest.fn(), | ||
clearPatches: jest.fn(), | ||
lambda: jest.fn(), | ||
handleUncaughtExceptions: jest.fn(), | ||
captureError: jest.fn(), | ||
currentTraceparent: null, | ||
currentTraceIds: {}, | ||
startTransaction: jest.fn().mockReturnValue(null), | ||
setTransactionName: jest.fn(), | ||
endTransaction: jest.fn(), | ||
currentTransaction: null, | ||
startSpan: jest.fn(), | ||
currentSpan: null, | ||
setLabel: jest.fn().mockReturnValue(false), | ||
addLabels: jest.fn().mockReturnValue(false), | ||
setUserContext: jest.fn(), | ||
setCustomContext: jest.fn(), | ||
addFilter: jest.fn(), | ||
addErrorFilter: jest.fn(), | ||
addSpanFilter: jest.fn(), | ||
addTransactionFilter: jest.fn(), | ||
addMetadataFilter: jest.fn(), | ||
flush: jest.fn(), | ||
destroy: jest.fn(), | ||
registerMetric: jest.fn(), | ||
setTransactionOutcome: jest.fn(), | ||
setSpanOutcome: jest.fn(), | ||
middleware: { | ||
connect: jest.fn().mockReturnValue(jest.fn()), | ||
}, | ||
logger: { | ||
fatal: jest.fn(), | ||
error: jest.fn(), | ||
warn: jest.fn(), | ||
info: jest.fn(), | ||
debug: jest.fn(), | ||
trace: jest.fn(), | ||
}, | ||
}; | ||
|
||
module.exports = agent; |