問題描述
我在 Angular 1.x 中使用 Protractor.我想逐步遷移到 Angular 2.0,但我沒有在文檔中看到 Protractor /a>.
自 Angular 2 以來量角器是否已被刪除?我應(yīng)該在不使用 Protractor 的情況下編寫測試,而是使用 Jasmine(或其他)嗎?
您可以使用 Protractor
測試 Angular 2 應(yīng)用程序(從 Protractor 2.5.0 開始).p>
對(duì)于 Protractor 5.0.0+,您不需要不必做任何具體的事情,Protractor 將自動(dòng)檢測被測應(yīng)用程序中使用的 Angular 版本.
對(duì)于 Protractor >= 2.5.0 和 <= 4.0.14,您只需將 useAllAngular2AppRoots: true
添加到您的配置中.這是一個(gè)示例.
請(qǐng)注意,一些內(nèi)置的 Protractor 匹配器尚不能與 Angular2 一起使用,請(qǐng)參閱:
- Protractor Angular 2 失敗:未知錯(cuò)誤:未定義角度
Firefox中還有那個(gè)Protractor+Angular2的問題(還沒解決),見:
- 無法運(yùn)行 Selenium更新到 Angular 2 后通過 Firefox 上的量角器
I use Protractor with Angular 1.x. I would like to migrate to Angular 2.0 step by step but I don't see Protractor in the docs.
Has protractor been dropped since Angular 2? Should I write my tests without using Protractor, using Jasmine instead (or others)?
You can test Angular 2 applications with Protractor
(starting from Protractor 2.5.0).
For Protractor 5.0.0+, you don't have to do anything specific, Protractor will auto-detect the Angular version used in the application under test.
For Protractor >= 2.5.0 and <= 4.0.14, you would only need to add useAllAngular2AppRoots: true
to your config. Here is a sample.
Note that several built-in Protractor matchers would not yet work with Angular2, see:
- Protractor Angular 2 Failed: unknown error: angular is not defined
There is also that Protractor+Angular2 problem in Firefox (still unresolved), see:
- Can't run Selenium via Protractor on Firefox after update to Angular 2
這篇關(guān)于如何在 Angular 2 中使用量角器?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!