gpt4 book ai didi

javascript - 加快在 Chrome 中运行的测试

转载 作者:行者123 更新时间:2023-11-29 16:57:57 25 4
gpt4 key购买 nike

这是基于this question发现当 Chrome 不在前台时,测试运行得非常慢。任何人都知道如何解决这个问题以便我可以继续使用 Chrome,但不必将其保留在前台?

最佳答案

以 headless 模式运行 chrome。我看到了惊人的性能提升。

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

关于javascript - 加快在 Chrome 中运行的测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30807472/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com