Wallaby.js supports the Facebook Jest testing framework.

module.exports = function () {

  return {
    files: ['src/**/*.js', '!src/**/__tests__/*.js'],

    tests: ['src/**/__tests__/*.js'],

    env: {
      type: 'node',
      runner: 'node'
    },

    testFramework: 'jest'
  };
};

You may find the working sample of wallaby.js configuration for Jest in this repository.

jest

Please note that wallaby.js is using its own cache to run your tests from, not the local project folder. You should include all files (except node modules) that your tests need, for example __mocks__/*.*, etc.

Jest configuration

If Jest in your project is configured using package.json or jest.config.js file, then wallaby will automatically load the configuration. If you would like to adjust the configuration, you may use the setup function, and pass require('./package.json').jest (or require('./jest.config.js')) to the wallaby.testFramework.configure function. Don’t forget to include package.json/jest.config.js in your files list in this case.

 module.exports = function () {

   return {
     files: [
       'src/**/*.js',
       'package.json', // <--
       '!src/**/__tests__/*.js'
       ],

     tests: ['src/**/__tests__/*.js'],

     env: {
       type: 'node',
       runner: 'node'
     },

     testFramework: 'jest',

     setup: function (wallaby) {
       var jestConfig = require('./package.json').jest;
       jestConfig.globals = { "__DEV__": true };
       wallaby.testFramework.configure(jestConfig);
     }
   };
 };

If you have some other Jest config, or would like to override some configuration values, you may pass any config object to the configure function of the test framework in wallaby setup function.

TypeScript

TypeScript Jest configuration (ts-jest modules to be more specific) requires the access to the tsconfig.json file, so if you are using Jest with TypeScript, you’ll need to add the file to your files list:

module.exports = function () {

  return {
    files: [
      'tsconfig.json', // <--
      'src/**/*.ts',
      '!src/**/__tests__/*.ts'
      ],

    tests: ['src/**/__tests__/*.ts'],

    env: {
      type: 'node',
      runner: 'node'
    },

    testFramework: 'jest'
  };
};

Snapshot testing

It’s recommended to read the article about Jest snapshot testing workflow with wallaby.js. Amongst other things, the article describes how to update individual test snapshots:

jest snapshots

You may also find a couple of snapshot testing notes/recipes with jest plus wallaby.js in this question discussion.

create-react-app

You may find the full config for create-react-app generated app in this docs section.

scriptPreprocessor

If you are using scriptPreprocessor for some source files that you’d like to see wallaby coverage for, you’ll need to use wallaby preprocessor or wallaby compiler instead. For example, TypeScript or CoffeeScript compiler or Babel compiler.