wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
759 stars 45 forks source link

If `jest` integration stopped working or became slow after updating wallaby core to 1.0.325 #880

Closed ArtemGovorov closed 7 years ago

ArtemGovorov commented 7 years ago

There was a breaking change and now wallaby jest runner sets rootDir to be the local project folder as opposed to the wallaby cache folder.

While we believe we have addressed a few possible issues with the change, so hopefully most of users will not notice the change, there still may be some scenarios that could be broken.

If you had wallaby.js working with jest before updating to 1.0.325 and it stopped woking after the update, please report the issue here, and attach your wallaby and jest config.

To switch back to the old default value, you may point the rootDir to the wallaby cache:

 module.exports = function () {

   return {
     ...

     setup: function (wallaby) {
       var jestConfig = {
         ...
         rootDir: wallaby.projectCacheDir
       };
       wallaby.testFramework.configure(jestConfig);
     }
   };
 };

or, if you're loading the config from the package.json:

 module.exports = function () {

   return {
     ...

     setup: function (wallaby) {
       var jestConfig = require('./package.json').jest;
       jestConfig.rootDir = wallaby.projectCacheDir;
       wallaby.testFramework.configure(jestConfig);
     }
   };
 };
dylanparry commented 7 years ago

I'm getting extremely poor performance in VSCode using Jest, but pretty sure it was okay a day or so ago. Could this be something to do with this change?

What I'm experiencing is that whenever I start typing something like import Foo from '... the processor usage spikes as soon as I start typing the path part and VSCode becomes very unresponsive. I'm also seeing similar behaviour whenever I start typing a new test with a describe block. It seems that whenever I get to a bit where I need to provide a string value things start going incredibly slow.

I know this is vague, but it's hard to explain without showing :)

Any ideas?

Edit: I have added the config you show above and the performance issues have disappeared, so I'm guessing it must be something to do with this new caching method, although what exactly it is I haven't a clue...

ArtemGovorov commented 7 years ago

@dylanparry Thanks for reporting the issue and checking that it works ok with reverting back to the previous default value for the rootDir. Could you please attach your wallaby config, jest config and package.json?

ArtemGovorov commented 7 years ago

@dylanparry Also, if it's possible, please share a test file where the issue shows up. If it's reproducible even on simple test files, it's even better.

We're planning to deprecate the old caching method soon, so really appreciate your help with sorting out the performance issue with the new caching method.

ArtemGovorov commented 7 years ago

@dylanparry Please try the latest core v1.0.328 to see if it fixes the performance issue for you.

dylanparry commented 7 years ago

Thanks, @ArtemGovorov. The update to core seems to have fixed it.

For reference, here's my setup:

wallaby.js

const babelConfig = {
    presets: ['latest', 'react'],
};

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

        tests: [
            'tests/**/*.js',
            'tests/**/*.jsx',
        ],

        compilers: {
            '**/*.js': wallaby.compilers.babel(babelConfig),
            '**/*.jsx': wallaby.compilers.babel(babelConfig),
        },

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

        testFramework: 'jest',

        // setup: () => {
        //     wallaby.testFramework.configure({
        //         rootDir: wallaby.projectCacheDir,
        //     });
        // },
    };
};

package.json

{
  "name": "automaton",
  "version": "1.0.0",
  "description": "Home Automation software for Raspberry Pi",
  "main": "./main.js",
  "author": "Dylan Parry",
  "license": "MIT",
  "private": true,
  "dependencies": {
    "babel-core": "^6.18.2",
    "babel-loader": "^6.2.8",
    "babel-preset-latest": "^6.16.0",
    "babel-preset-react": "^6.16.0",
    "cross-env": "^3.1.3",
    "electron": "^1.4.7",
    "eslint": "3.9.1",
    "eslint-config-airbnb": "^13.0.0",
    "eslint-plugin-import": "2.1.0",
    "eslint-plugin-jsx-a11y": "2.2.3",
    "eslint-plugin-react": "6.6.0",
    "jest": "^17.0.3",
    "mobx": "^2.6.3",
    "mobx-react": "^4.0.0",
    "react": "^15.4.0",
    "react-dom": "^15.4.0",
    "webpack": "2.1.0-beta.26"
  },
  "scripts": {
    "start": "electron .",
    "development": "cross-env NODE_ENV=development webpack --watch --progress --colors",
    "production": "cross-env NODE_ENV=production webpack --progress --colors",
    "test": "jest",
    "lint": "eslint ./ --ext .jsx,.js --ignore-pattern dist"
  }
}

Demo file

import MetadataMessage from '../../src/messages/metadata-message';

import RadiatorThermostat from '../../src/devices/radiator-thermostat';
import WallMountedThermostat from '../../src/devices/wall-mounted-thermostat';

describe('MetadataMessage', () => {
    it('returns the correct number of rooms', () => {
        const sut = new MetadataMessage('VgICARNIYWxsL1N0YWlycy9MYW5kaW5nExl2AgZPZmZpY2UTH+IEARMZdk1FUTE0NDU2MDIXUmFkaWF0b3IgU2Vjb25kIExhbmRpbmcBARMKQ01FUTE0NDI3NDkWUmFkaWF0b3IgRmlyc3QgTGFuZGluZwEDFO42TkVRMDA4NTcwMA9XYWxsIFRoZXJtb3N0YXQBARMf4k1FUTE0NDcyNjEIUmFkaWF0b3ICAQ==');

        expect(sut.roomCount).toBe(2);
    });

I don't have a config for jest, it's just using whatever the defaults are.

The problem began as soon as started typing the MetadataMessage part of the describe block, and also when I was typing in the paths for the import statement.

As I said, it seems to have cleared up since updating to the latest core version though, so hopefully it's all sorted now.

Thanks!

ArtemGovorov commented 7 years ago

@dylanparry Awesome, thanks for checking and sharing the setup! I believe the issue is fixed now.