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 you have some Jest config, pass the config object to the configure function of the test framework in wallaby setup function.

If Jest is configured using your package.json, you may use the setup function, and pass require('package.json').jest to the wallaby.testFramework.configure function. Don’t forget to include package.json in your files list in this case.

 module.exports = function () {

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

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

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

     testFramework: 'jest'

     setup: function (wallaby) {
       wallaby.testFramework.configure({
         // https://facebook.github.io/jest/docs/api.html#config-options
         // you may just pass `require('./package.json').jest`, if you use it for your Jest config
         // don't forget to include package.json in the files list in this case
       });
     }
   };
 };

Snapshot testing

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

If you are using TypeScript with jest and doing snapshot testing, you may need a preprocessor to rename snapshots of the fly.

module.exports = function () {
    return {
        ...
        preprocessors: {
            '**/*.snap': file => (
                file.rename(file.path.replace('.tsx', '.js').replace('.ts', '.js')),
                file.content)
        },
        ...
    };
};

This is required because wallaby renames compiled .ts/.tsx to .js/.jsx, and then jest produces the snapshot.js.snap-like name.

TypeScript

If you are using TypeScript with jest, you need to have .js/.jsx extensions listed before .ts/.tsx in your moduleFileExtensions, or have them deleted from the jest config in wallaby.js.

"moduleFileExtensions": [
      "js",
      "jsx",
      "ts",
      "tsx"
    ],

This is required because wallaby runs tests from its own cache where it stores both raw .ts/.tsx files and instrumented .js/.jsx, so setting a higher priority for .js/.jsx files is required.

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.