Introduction: Configuration

Automatic configuration

For some testing frameworks and environments Wallaby requires no configuration at all. Right now we support automatic configuration for Jest testing framework (from v24) and Angular CLI (Jasmine + Webpack) starting from v8.2.

If automatic configuration for your testing framework is not supported yet, you may continue to use Wallaby with a simple configuration file.

VS Code

To start Wallaby without configuration in VS Code you may run Select Configuration command and then select Automatic Configuration <project directory> option once. After that you may keep using Wallaby Start command as usual and it will start Wallaby with automatic configuration.

JetBrains IDEs

To start Wallaby without a configuration file in JetBrains IDEs, you may edit (or create a new) wallaby.js Run Configuration by selecting Edit configurations from the drop-down menu in the top right-hand corner of the navigation bar, or from the Run menu. In the run configuration editor set Configuration Type filed value to Automatic.

Atom

To start Wallaby without configuration in Atom you may use the Select for Wallaby.js Automatic Configuration context menu item for your project folder in the project’s file tree. After that you may keep using Wallaby Start command as usual and it will start Wallaby with automatic configuration.

Visual Studio

To start Wallaby without a configuration file in Visual Studio, you may use the Start Wallaby.js (Automatic Configuration) context menu item for your project folder in the Solution Explorer. After the first start, the selected project will be remembered for your solution and Wallaby can be started with Tools->Start Wallaby.js (Alt-W, 1).

Sublime Text

To start Wallaby without configuration in Sublime Text you may use the Select for Wallaby.js Automatic Configuration context menu item for your project folder in the project’s file tree. After that you may keep using Wallaby Start command as usual and it will start Wallaby with automatic configuration.

Overriding automatic defaults

In order to override any defaults, you may use Wallaby Configuration file or wallaby section in your package.json file, specify the autoDetect: true setting and then any Wallaby settings that you want to add/override:

package.json

{
  "name": "...",
  ...
  
  "dependencies": {
    ...
  },
  
  "devDependencies": {
    ...
  },
  
  ...
  
  "wallaby": {
    "autoDetect": true,
    ...
  }
}

wallaby.js

module.exports = () => ({
   autoDetect: true,
   ...
});

Configuration file

Wallaby.js configuration file lists your files/tests and describes the build/setup process for your testing environment.

For example, if you are using a compiler or a module bundler, it needs a configuration for the compiler, such as Babel or TypeScript compiler, or the module bundler, such as Browserify or Webpack.

These things are configured in wallaby.js configuration file, that should be placed to your project root folder. Recommended name is wallaby.js or wallaby.conf.js.

The configuration file is a simple JavaScript file, with a root object containing the properties listed below or exporting a function that returns an object of the same structure.

For example:

module.exports = function (wallaby) {
  return {
    files: [
      'src/**/*.js'
    ],

    tests: [
      'test/**/*Spec.js'
    ]
    ...
    // for node.js tests you need to set env property as well
    // https://wallabyjs.com/docs/integration/node.html
  };
};

By default wallaby.js is using PhantomJs to run tests. If you want to use wallaby.js to run your node.js tests, or run your tests in Google Chrome, or in the latest Chromium/V8 via Electron, or run your tests in a different version of PhantomJs, you will also need to specify env configuration property.

You may read more about various configuration settings, such as files, in the corresponding documentation sections. For example, how to configure wallaby to use Webpack or Babel.

Configuration in package.json

You may use wallaby section in your package.json file to configure Wallaby.js, specify some settings in addition to those specified in your Wallaby config file, or to or override automatic configuration mode defaults:

package.json

{
  "name": "...",
  ...
  
  "dependencies": {
    ...
  },
  
  "devDependencies": {
    ...
  },
  
  ...
  
  "wallaby": {
    "slowTestThreshold": 200
  }
}