Skip to content

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.

  • Logger

new TestLogger(originalLogger?): TestLogger

Defined in: src/testing/test-logger.ts:16

Create a new test logger that wraps the given logger if provided.

Logger

The optional original logger to wrap.

TestLogger

get capturedLogs(): string[]

Defined in: src/testing/test-logger.ts:22

Returns all logs captured thus far.

string[]

clear(): void

Defined in: src/testing/test-logger.ts:27

Clears all logs captured so far.

void


debug(message, …optionalParams): void

Defined in: src/testing/test-logger.ts:80

string

unknown[]

void

Logger.debug


error(message, …optionalParams): void

Defined in: src/testing/test-logger.ts:64

string

unknown[]

void

Logger.error


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

LogSnapshotConfig

The snapshot configuration

string

The snapshotted logs.

const logger = new TestLogger()
...
expect(logger.getLogSnapshot()).toMatchSnapshot()

info(message, …optionalParams): void

Defined in: src/testing/test-logger.ts:72

string

unknown[]

void

Logger.info


verbose(message, …optionalParams): void

Defined in: src/testing/test-logger.ts:76

string

unknown[]

void

Logger.verbose


warn(message, …optionalParams): void

Defined in: src/testing/test-logger.ts:68

string

unknown[]

void

Logger.warn