Wallaby.js supports different environments including Google Chrome, node.js, Chromium/V8 via Electron and PhantomJs. By default, Google Chrome (headless) is used as the test runner environment. You may use the env
configuration property to specify a different test runner or change the runner settings.
module.exports = function () {
return {
files: [
'lib/**/*.js'
],
tests: [
'test/**/*Spec.js'
],
env: {
type: '...',
runner: '...'
params: {
runner: '...',
env: '...'
}
}
};
};
env.type
should be set to 'node'
to use node.js, or set to 'browser'
to use a browser environment (PhantomJs or Electron). The default value is 'browser'
.
env.kind
should be set to 'chrome'
to use locally installed Google Chrome as a test runner, or to 'electron'
to use Electron test runner, or set to 'phantomjs'
to use PhantomJs. The default value is 'chrome'
.
env.options
allows you to pass an object of Electron BrowserWindow options.
env.runner
should be set to your local node/phantomJs/electron path, or just node
/phantomjs
(or any other command) that is mapped to your test runner binary. If env.type
is set to node
but env.runner
is not set, wallaby.js will use its own version of node.js or the system default one.
env.params.runner
allows you to set space-separated spawned runner process flags.
env.params.env
allows you to set semicolon-separated spawned runner process environment variables.
env.viewportSize
allows you to set PhantomJs/Electron page viewport size; the default value is {width: 800, height: 600}
.
The env.report404AsError
boolean property allows you to report any 404 server hits as errors to Wallaby Console; the default value is false
. It can be useful if you’d like to be alerted when your tests are requesting some missing resources or accessing missing server API, etc.
Please note that env
settings are for test runner workers, not for preprocessors, postprocessor and compilers. If you need to pass some process.env
settings to Babel compiler or Webpack postprocessor, you may do it by setting the properties right in wallaby.js configuration file. For example:
// whenever wallaby loads the config file (and later uses babel),
// babel will know that we are in the `test` env
process.env.BABEL_ENV = 'test';
module.exports = function (wallaby) {
return {
files: [...],
tests: [...],
compilers: {...}
...
};
};
Node.js
The configuration file for node.js may look as follows:
module.exports = function () {
return {
files: [
'lib/**/*.js'
],
tests: [
'test/**/*Spec.js'
],
env: {
type: 'node'
}
};
};
You may find the description of more configuration options for node.js environment in the node.js integration docs section.