简体   繁体   English

Angular Karma 测试 - Chrome 与 ChromeHeadless 的浏览器属性

[英]Angular Karma Testing - browser property as Chrome vs ChromeHeadless

I'm working in an Angular 9 project, and we're running tests with Karma.我在一个 Angular 9 项目中工作,我们正在使用 Karma 运行测试。

Can anyone explain to me the difference between setting the browser property (in karma.conf.js ) as Chrome and ChromeHeadless ?谁能向我解释将浏览器属性(在karma.conf.js )设置为ChromeChromeHeadless

The only real I see is that is the browser is set to Chrome , then a chrome window will automatically open when I run the tests, stays open as I edit tests (with live changes because I have the autoWatch property set to true and singleRun set to false).我看到的唯一真实情况是浏览器设置为Chrome ,然后当我运行测试时将自动打开一个 chrome 窗口,在我编辑测试时保持打开状态(实时更改,因为我将 autoWatch 属性设置为 true 和 singleRun 设置为假)。 When I stop the tests in the terminal.当我停止终端中的测试时。 that window will close.那个窗口会关闭。 It seems very convenient to me.对我来说似乎很方便。

And then's there's ChromeHeadless , which does all the above except I have to open the chrome window myself (and close it once I'm done).然后是ChromeHeadless ,它可以完成上述所有操作,除了我必须自己打开 chrome 窗口(完成后关闭它)。

Is this the only difference?这是唯一的区别吗? Is there anything else happening that would make me pick one over the other?还有什么其他事情会让我选择一个而不是另一个吗?

Usually when you are using a CI(Continious Integration) system like Jenkins to automaticaly run tests it does not have an "interface" to run Chrome.通常,当您使用像 Jenkins 这样的 CI(持续集成)系统来自动运行测试时,它没有运行 Chrome 的“接口”。 So in order to execute those End to End tests you need to execute them doing a "simulation" of a browser interface.因此,为了执行这些端到端测试,您需要对浏览器界面进行“模拟”来执行它们。 That's when ChromeHeadless comes to play.这就是 ChromeHeadless 发挥作用的时候。 It's completelly emulating a Chrome browser behaviour but without an interface.它完全模拟了 Chrome 浏览器的行为,但没有界面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM