Skip to main content

โš™๏ธ Configuration

By default, the test runner WILL NOT utilize ANY config loader

It will not know or care about:

  • your .env file
  • the current state of process.env
  • that ini file
  • any value outside of module declared default

Overriding module configsโ€‹

@digital-alchemy utilizes the config object for both key storage, as well as logic gates.

You can override these in 2 primary ways:

.configureโ€‹

Hard coded overrides to module values. This is equivalent to providing values at .bootstrap in priority

testRunner.configure({
synapse: {
// don't touch my real database!
SQLITE_DB: join(cwd(), "jest_sqlite.db")
}
})

config loaderโ€‹

You can also utilize a custom config loader as past of the test runner extended bootstrap options.

Loggingโ€‹

By default, the test runner will use a NOOP logger that will black hole basically all messages. Once your test is running as expected, this cuts down on general log spam.

If you are debugging and want access to logs, that can be accomplished with the .emitLogs() command.

// emits trace by default
testRunner.emitLogs();

// custom level
testRunner.emitLogs("warn");

Extended Optionsโ€‹

The full suite of options are exposed

TypeKeyDefaultDescription
LoggingemitLogsfalseIf true, default logger is left in place
LoggingcustomLoggerNOOP / defaultProvide alternate logger (createMockLogger)
LoggingloggerOptions{}Docs
LifecyclebootLibrariesFirstfalseSet to true if testing an application with that requirement
LifecycleforceTeardownfalseSet to true if your app requires running teardown hooks
Configurationconfiguration{}passed through to .bootstrap call
ConfigurationloadConfigsfalseAka do not consider configuration not provided in test / module explicitly
ConfigurationconfigLoaderundefinedInvoked during the config loading step to provide data

๐Ÿ—’๏ธ Logging note:

Errors that result in application termination (like test failures) are logged directly to console.error. They always appear in the output.