我希望能够对我的自定义聚合物元素进行单元测试。
给定 lib/web_components 中的一个组件:
class Foo extends PolymerElement {
Foo.created() : super.created();
}
和 test/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