Speed up tests run in Chrome

你说的曾经没有我的故事 提交于 2019-12-24 03:33:32

问题


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?


回答1:


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);
}



回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/30807472/speed-up-tests-run-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!