Speed up tests run in Chrome

742 views Asked by At

This is based on this question where it was discovered that when Chrome is not in the foreground, the tests run really slow. Anyone know how to get around that so I can continue to use Chrome, but don't have to keep it in the foreground?

3

There are 3 answers

0
kentcdodds On BEST ANSWER

There is currently no way to do this, but there is an issue to bring support for it back. Follow that for updates.

0
jsmapr1 On

A more manual trick that works on Macs is to put the chrome window in full screen mode in a space that is off screen.

It takes an extra click every time you start the test suite, but if you are watching the tests then you only have to do it once. You get all the performance improvements and don't have to worry about keeping chrome in the foreground.

1
David On

Run chrome in headless mode. I've seen a fantastic performance improvement.

gulp.task('test-headless-chrome', function (done) {
  process.env.DISPLAY=':95';

  withXvfb(function(stop) {
    server.start({
      configFile: __dirname + '/../karma/karma.conf.js',
      singleRun: true
    }, function() {
      stop();
      done();
    });
  });
});

function withXvfb(op) {
    var child = spawn('Xvfb', [':95', '-ac', '-screen', '0', '1600x1200x24'], {
            stdio: 'inherit'
    });

    setTimeout(op(function() {
        console.log("Killing Xvfb...")
        child.kill();
    }),3000);
}