The built-in library 'dart:html' is not available on the stand-alone VM -


i'd able unit test custom polymer elements.

given component in lib/web_components:

class foo extends polymerelement {   foo.created() : super.created(); } 

and test in test/web_components:

main() {   test("should polymerelement", (){     foo undertest = new foo.created();      expect(undertest, new isinstanceof<polymerelement>());   }); } 

running test results in error mentioned in title. how can avoid error?

edit:

so i've tried adding @teston('content-shell') @ top of client side test files, , adding @teston('vm') server side tests.

in grinder have:

@task('test') test() {   new pubapp.local('test').run([]);   new pubapp.local('test').run(["-p", "content-shell"]); } 

the server-side tests run fine client-side tests throw following error:

pub run test -p content-shell test/web_component/foo_test.dart   "failed start content shell: no such file or directory" 

edit 2:

i've tried running in dartium platform following command since content-shell doesn't seem work:

pub run test:test -p dartium test/web_component/foo_test.dart 

the result is:

failed load "test/web_component/foo_test.dart": type 'test.backend.declarer.declarer' not 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 

you need create html page test , run test in browser. new test package has decent readme explaining how that. (i have issue browser tests time out often. known issue , fixed soon.)

update see instantiating polymer element via dart code, dynamically create polymer element how create polymer element dynamically.

instead of main() use

@whenpolymerready init() { 

@teston('content-shell') ok it's better use @teston('browser') , specify concrete browser using -p argument (-pchrome, -pdartium, -pfirefox, -pcontent-shell, ... see test readme list of supported browsers). can pass more 1 -p @ time run tests @ more 1 browser.

you can use custom html page test

<!doctype html> <!-- custom_html_test.html --> <html>   <head>     <title>browser/polymer test</title>     <link rel="import" href="app_element.html">     <link rel="import" href="child_element.html">     <link rel="x-dart-test" href="html_test.dart">     <script src="packages/test/dart.js"></script>   </head>   <body>     <div id="granny">       <div>         <div id="parent">           <div>             <div id="child">child</div>           </div>         </div>       </div>     </div>     <app-element id="polymer-parent" unresolved>       <child-element id="polymer-child"></child-element>     </app-element>   </body> </html> 

where file names needs same dart test file except .html file extension , <link rel="x-dart-test" href="html_test.dart"> refers dart test file. app-element, child-element polymer elements used in test (like foo)

another update assume need use custom html file (not tried without yet) polymer tests because otherwise there no way register entry point transformer. , add html file entry point polymer transformer section in pubspec.yaml


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -