飛鏢中的web-ui測試沒有太多文檔。有兩種方法可用:a)運行Chrome的DumpRenderTree或b)包含loading the app as is and running the test code on top of it的技巧。對於微不足道的情況,第一個選項似乎有點乏味。所以後面的選項 - 在我的情況下,在加載組件時不起作用。如何測試Dart中的Web組件?
用下面的文件結構:
test/
main_test.html
main_test.dart
web/
main.html
app.html
(all the files are listed in this gist)
以下測試組掛在第二步驟。
main() {
useShadowDom = true;
test('Inline element is initially present.',() {
var story =() => expect(query('#hdr'), isNotNull);
Timer.run(expectAsync0(story));
});
test('Component is loaded.',() {
var story =() => expect(query('#globe'), isNotNull);
Timer.run(expectAsync0(story));
});
}
應用程序組件如何加載?更廣泛地說,是否有另一種測試Web組件的方法?