jestjsts-jestwallaby.js

Can't run wallaby.js with jest in vscode


I have a project with jest and typescript. When I run jest, the tests run correctly. I prepared the wallaby.config.js file:

// wallaby.config.js
export default function () {
  return {
    autoDetect: true,
    trace: true,
    files: ['src/**', '!**/*Spec.ts'],
    tests: ['__tests__/**/*Spec.ts'],
    debug: true,
    env: {
      type: 'node',
      runner: 'node',
    },
  };
}

When I try to start I get:

Failed to initialize wallaby jest. 
Failed to read Jest configuration from '.': m is not defined 

My packages.json as type = "module"

Also, my jest.config.js looks like:

export default {
  verbose: true,
  testMatch: ['<rootDir>/__tests__/**/*.ts'],
  preset: 'ts-jest',
  testEnvironment: 'node',
};

As I said at begin, if I type npx jest works correctly.

I want wallaby working on my vscode.


Solution

  • Finally I found a workaround.

    First of all install jasmine and esm as dev dependency.

    Now update the wallay.config.js file:

    export default function configure(wallaby) {
      return {
        trace: true,
        files: ['src/**', '!**/*Spec.ts'],
        tests: ['__tests__/**/*Spec.ts'],
        debug: true,
        testFramework: 'jasmine',   //  <- added
        env: {
          type: 'node',
          runner: 'node',
          params: {                 // 
            runner: `-r esm`,       //  <- added
          },                        //
        },
      };
    }
    

    Now all work. I'm running test manually with jest and wallaby is using jasmine. It doesn't seem best way but works for now.