TestLogger
Defined in: src/testing/test-logger.ts:8
Exposes an AlgoKit logger which captures log messages, while wrapping an original logger. This is useful for automated testing.
Implements
Section titled “Implements”Logger
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TestLogger(
originalLogger?):TestLogger
Defined in: src/testing/test-logger.ts:16
Create a new test logger that wraps the given logger if provided.
Parameters
Section titled “Parameters”originalLogger?
Section titled “originalLogger?”Logger
The optional original logger to wrap.
Returns
Section titled “Returns”TestLogger
Accessors
Section titled “Accessors”capturedLogs
Section titled “capturedLogs”Get Signature
Section titled “Get Signature”get capturedLogs():
string[]
Defined in: src/testing/test-logger.ts:22
Returns all logs captured thus far.
Returns
Section titled “Returns”string[]
Methods
Section titled “Methods”clear()
Section titled “clear()”clear():
void
Defined in: src/testing/test-logger.ts:27
Clears all logs captured so far.
Returns
Section titled “Returns”void
debug()
Section titled “debug()”debug(
message, …optionalParams):void
Defined in: src/testing/test-logger.ts:80
Parameters
Section titled “Parameters”message
Section titled “message”string
optionalParams
Section titled “optionalParams”…unknown[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Logger.debug
error()
Section titled “error()”error(
message, …optionalParams):void
Defined in: src/testing/test-logger.ts:64
Parameters
Section titled “Parameters”message
Section titled “message”string
optionalParams
Section titled “optionalParams”…unknown[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Logger.error
getLogSnapshot()
Section titled “getLogSnapshot()”getLogSnapshot(
config?):string
Defined in: src/testing/test-logger.ts:47
Returns a captured log snapshot. This helps ensure that the provided configuration items won’t appear with random values in the log snapshot, but rather will get substituted with predictable ids.
https://jestjs.io/docs/snapshot-testing#2-tests-should-be-deterministic
Parameters
Section titled “Parameters”config?
Section titled “config?”The snapshot configuration
Returns
Section titled “Returns”string
The snapshotted logs.
Example
Section titled “Example”const logger = new TestLogger()...expect(logger.getLogSnapshot()).toMatchSnapshot()info()
Section titled “info()”info(
message, …optionalParams):void
Defined in: src/testing/test-logger.ts:72
Parameters
Section titled “Parameters”message
Section titled “message”string
optionalParams
Section titled “optionalParams”…unknown[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Logger.info
verbose()
Section titled “verbose()”verbose(
message, …optionalParams):void
Defined in: src/testing/test-logger.ts:76
Parameters
Section titled “Parameters”message
Section titled “message”string
optionalParams
Section titled “optionalParams”…unknown[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Logger.verbose
warn()
Section titled “warn()”warn(
message, …optionalParams):void
Defined in: src/testing/test-logger.ts:68
Parameters
Section titled “Parameters”message
Section titled “message”string
optionalParams
Section titled “optionalParams”…unknown[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Logger.warn