问题
browser tests need to be run from command line like pub run test -pdartium
. Is there a way to debug such tests.
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/33165457/how-to-debug-browser-tests-with-the-new-test-package