0

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.

David
  • 923
  • 8
  • 19
  • 1
    The error message means you are on an older version of Wallaby that doesn't support the version of Jest that you are using. – Artem Govorov Apr 06 '22 at 00:47
  • Thank you @ArtemGovorov. It makes sense because my license is a little old. But the message should be more clear. Ty again. – David Apr 06 '22 at 09:33

1 Answers1

0

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.

David
  • 923
  • 8
  • 19