我希望能夠對我的定製聚合物元素進行單元測試。獨立VM上沒有內置庫「dart:html」
給定一個部件在LIB/web_components:
class Foo extends PolymerElement {
Foo.created() : super.created();
}
和在測試/ web_components測試:
main() {
test("Should Be a PolymerElement",(){
Foo undertest = new Foo.created();
expect(undertest, new isInstanceOf<PolymerElement>());
});
}
運行在在標題中提到的錯誤的測試結果。我怎樣才能避免這個錯誤?
編輯:
所以我試着在我的客戶端測試文件的頂部添加@TestOn('content-shell')
,並添加@TestOn('vm')
到服務器端的測試。
在磨牀我:
@Task('Test')
test() {
new PubApp.local('test').run([]);
new PubApp.local('test').run(["-p", "content-shell"]);
}
服務器端的測試運行正常,但在客戶端測試拋出以下錯誤:
pub run test -p content-shell test/web_component/foo_test.dart
"Failed to start content shell: No such file or directory"
編輯2:
我我嘗試在dartium平臺上運行以下命令,因爲content-shell似乎不起作用:
pub run test:test -p dartium test/web_component/foo_test.dart
結果是:
Failed to load "test/web_component/foo_test.dart": type 'test.backend.declarer.Declarer' is not a subtype of type 'test.backend.declarer.Declarer' of 'function result'.
packages/test/test.dart 44:32 _declarer
packages/test/test.dart 108:5 test
foo_test.dart 9:3 main
package:test IframeListener.start
foo_test.dart.browser_test.dart 6:18 main
再次更新,因爲我忘記了您需要註冊變壓器的入口點。 –
感謝您的更新。目標是讓這些測試在持續集成服務器上運行。這就是爲什麼我嘗試使用'content-shell'的原因,因爲我認爲我需要一個無頭虛擬機來管理drone.io。 – ZeroDivide
您可以在測試文件中使用通用的'@TestOn('browser')',然後在運行測試'pub run test -pcontent-shell'時指定具體的瀏覽器。 –