Intern's usage over the last couple of years has exposed some areas for improvement in Intern's configuration system.
Problems
The main problems are:
The config-processing logic is spread out and can be hard to follow
The merging logic is inconsistent (#877)
The self tests aren't fully exercising the merge logic
Some of the default options aren't applied consistently, leading to issues like #877, where attempting to add a reporter to the default simply replaces the default.
Background
The current process is split between core/lib/<env>/util#getConfig, core/common/util#loadConfig, and core/lib/executors/<executor>#_resolveConfig.
Load a config file (the default or one given as a command line arg or query arg) - getConfig
Process the config file, normalizing config values and processing merge directives - loadConfig
Apply command line or query arguments - loadConfig
"Resolve" the config (expand globs) - _resolveConfig. During this process, defaults stored in the executors are applied.
The config file format is JSON+comments.
The config file format is intentionally a bit looser than the internal config format for ease of use. For example, a config file can use a string for the suites property, but in a Config structure the suites property is always an array of strings.
Various parts of the config file may be merged during processing:
A config that uses extends will be merged with whatever config it's extending
Child configs (children of a configs property) are merged with the parent config, or with the config they explicitly extend
Resource properties (suites, plugins) are implicitly added to resource properties in node and browser properties
A few properties (suites, plugins, instrumenterOptions, tunnelOptions) can be suffixed with a '+', in which case they'll be shallowly mixed into the current value of the property at the time they're processed
One substitution is currently performed: The string {pwd} in environment descriptors will be expanded to the current working directory at runtime.
Desired outcomes
Externalize the defaults
Apply the default config options currently setup in the executor constructors in the main config handling logic. The order should be:
Default config
Loaded config
Environment variables (INTERN_ARGS)
CLI / query args
This will require moving the default options into the config logic, or into separate environment-specific files.
Intern's usage over the last couple of years has exposed some areas for improvement in Intern's configuration system.
Problems
The main problems are:
Background
The current process is split between
core/lib/<env>/util#getConfig
,core/common/util#loadConfig
, andcore/lib/executors/<executor>#_resolveConfig
.getConfig
loadConfig
loadConfig
_resolveConfig
. During this process, defaults stored in the executors are applied.The config file format is JSON+comments.
The config file format is intentionally a bit looser than the internal config format for ease of use. For example, a config file can use a string for the
suites
property, but in a Config structure thesuites
property is always an array of strings.Various parts of the config file may be merged during processing:
extends
will be merged with whatever config it's extendingconfigs
property) are merged with the parent config, or with the config they explicitly extendsuites
,plugins
) are implicitly added to resource properties innode
andbrowser
propertiessuites
,plugins
,instrumenterOptions
,tunnelOptions
) can be suffixed with a '+', in which case they'll be shallowly mixed into the current value of the property at the time they're processedOne substitution is currently performed: The string
{pwd}
in environment descriptors will be expanded to the current working directory at runtime.Desired outcomes
Externalize the defaults
Apply the default config options currently setup in the executor constructors in the main config handling logic. The order should be:
INTERN_ARGS
)This will require moving the default options into the config logic, or into separate environment-specific files.
Merging should always be explicit.
Given this:
only
c.ts
should be used in a node environment. To get the existing behavior, use:Merging should always be shallow
Merging should be shallow (it is now). Users can use '+' suffixes to explicitly merge subproperties.
Improved test coverage