wallabyjs / public

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

Worker is not created in time, recycling it #397

Closed forkingpath closed 8 years ago

forkingpath commented 8 years ago

I'm not sure if I've misconfigured something or not, but I can't see any reason for this to be happening, & my tests and webpack configs work separately from wallaby.js. After loading and transpiling my app code and single test, the following output loops in the console:

Fri, 15 Jan 2016 01:10:29 GMT wallaby:workers Worker is not created in time, recycling it
Fri, 15 Jan 2016 01:10:29 GMT wallaby:project Test run cancelled, re-queueing run data
Fri, 15 Jan 2016 01:10:29 GMT wallaby:project Test run finished
Fri, 15 Jan 2016 01:10:29 GMT wallaby:project Test run data re-queued
Fri, 15 Jan 2016 01:10:29 GMT wallaby:project Running postprocessor
Fri, 15 Jan 2016 01:10:29 GMT wallaby:postprocessor Compiler re-created because some tracked files were added or deleted
Fri, 15 Jan 2016 01:10:30 GMT wallaby:postprocessor Emitting 136 files
Fri, 15 Jan 2016 01:10:31 GMT wallaby:project Postprocessor execution finished
Fri, 15 Jan 2016 01:10:31 GMT wallaby:project Test run started; run priority: 3
Fri, 15 Jan 2016 01:10:31 GMT wallaby:project Running all tests
Fri, 15 Jan 2016 01:10:31 GMT wallaby:workers Starting test run, priority: 3
Fri, 15 Jan 2016 01:10:31 GMT wallaby:nodeRunner Starting sandbox [worker #0, session #cot37]
Fri, 15 Jan 2016 01:10:31 GMT wallaby:nodeRunner Preparing sandbox [worker #0, session #cot37]
Fri, 15 Jan 2016 01:10:31 GMT wallaby:workers Starting run worker instance #0

It just repeats with different session #s. Not only that, but whatever number of workers I specify in wallaby.js, they all time out too. What's going on?

I can't find any docs about the workers that wallaby uses, so I don't know where to start. I tried to cut down my Webpack compilation time but it's holding steady at around 15s; either way it doesn't look like that's what is causing it to time out based on experimenting with the config.

ArtemGovorov commented 8 years ago

Could you please share your wallaby and webpack configs?

forkingpath commented 8 years ago

Some folder names changed to protect $dayjob.

var path = require('path');
var webpack = require('webpack');
var chai = require('chai');
var appRootPath = path.resolve(__dirname, "app");
var modulePath = path.resolve(appRootPath, 'vendor');
var wallabyWebpack = require('wallaby-webpack');
var buildConstants = require('./plugins/build_constants');
var babel = require('babel-core');
var wallabyPostprocessor = wallabyWebpack({
    externals: {
      "Backbone": "backbone",
      FB: "var FB"
    },
    plugins: [
      new webpack.DefinePlugin(buildConstants),
      new webpack.IgnorePlugin( /.scss$/ ),
      new webpack.ProvidePlugin(
        {
          "_": "underscore",
          "$": "jquery",
          "jquery": "jquery",
          "jQuery": "jquery",
          "React": "react",
          "react": "react",
          "isMobile": path.resolve(modulePath, "isMobile"),
          "hammer": path.resolve(modulePath, "hammer"),
          "Hammer": path.resolve(appRootPath, "vendor/hammer")
        })
    ],
  resolve: {
    fallback: path.resolve("./node_modules"),
    root: [
      appRootPath,
      path.resolve(appRootPath,"stores"),
      path.resolve(appRootPath,"jsx-templates/base/components"),
      path.resolve(appRootPath,"jsx-templates/base/dialogs"),
      path.resolve(appRootPath,"jsx-templates/base/"),
      path.resolve(appRootPath,"vendor"),
      path.resolve(appRootPath, "bower_components"),
      path.resolve(appRootPath,"../node_modules/gsap/src/uncompressed")
    ],
    extensions: ['', '.js', '.jsx', '.sass', '.css', '.scss']
  },
    module: {
      noParse: /(vendor|jquery|bower_components|gsap|json|scss|react\.js).*/
    }
  }
);

module.exports = function (wallaby) {
  return {
    env: {
      NODE_ENV: "test",
      BABEL_ENV: "test",
      type: 'node',
      runner: "C:\\phantomjs-2.0.0-windows\\bin\\phantomjs.exe"
    },
    files: [
      {pattern: 'node_modules/chai/chai.js', instrument: false},
      {pattern: 'node_modules/sinon-chai/sinon-chai.js', instrument: false},
      {pattern: 'node_modules/chai-as-promised/lib/chai-as-promised.js', instrument: false},
      {pattern: 'app/game-wrappers/*.js', load: false},
      {pattern: 'app/jsx-templates/base/*.jsx', load: false},
      {pattern: 'app/stores/**/*.jsx', load: false},
      {pattern: 'app/utils/**/*.js', load: false},
      {pattern: 'app/*.js', load: false}
    ],
    compilers: {
      'app/**/*.js*': file => babel.transform(file.content, {
        sourceMap: true,
        presets: ['react', 'stage-0', 'es2015'],
        plugins: ['transform-runtime', "babel-plugin-transform-decorators-legacy", 'rewire']
      })
    },
    tests: [
      {pattern: 'test/*Test.js', load: false}
    ],
    testFramework: 'mocha',
    postprocessor: wallabyPostprocessor,
    debug: true,
    bootstrap: function (wallaby) {
      window.__moduleBundler.loadTests();
    },
    workers: {
      initial: 6,
      regular: 3
    }
  };
};
ArtemGovorov commented 8 years ago

Thanks. It looks like you're trying to use 2 incompatible options:

env: {
      ...
      type: 'node',
      runner: "C:\\phantomjs-2.0.0-windows\\bin\\phantomjs.exe"
    },

type: 'node' supposed to be used when you'd like to run your tests in node.js. However, from the rest of your config it looks like you're running browser tests, so you should remove it (or specify type: 'browser' which is the default option value). Please also make sure the C:\\phantomjs-2.0.0-windows\\bin\\phantomjs.exe file exists.

forkingpath commented 8 years ago

Ah, I see. I had thought that because PhantomJS runs in node, it would be a node environment, but that's wrong! Thank you!

ArtemGovorov commented 8 years ago

Cool, let me know if you hit any other bumps configuring wallaby.js for your project, happy to help.