How to debug browser tests with the new test package

337 views Asked by At

browser tests need to be run from command line like pub run test -pdartium. Is there a way to debug such tests.

2

There are 2 answers

2
user7610 On BEST ANSWER
pub run test -pdartium --pause-after-load

starts the test only after I click a "play" button on the test page. This gives me time to open up Dev Tools in Dartium and set breakpoints. I can also open up the Observatory and do stuff there.

0
Günter Zöchbauer On

The Dart team is working hard to make tests with the new test package debuggable. Until the related issues are fixed you can use this workaround:

To run browser tests with the new test package, for example from WebStrom, including debugging, just replace the <x-test-dart ...> tag with a normal Dart script tag pointing to your test file and run it like any Dart browser application from WebStorm.

This also works for Polymer tests. Ensure you run await initPolymer(); or the appropriate initialization necessary for the used Polymer version.

I usually create a copy of the test entry page file where I can keep the replaced script tag.