From https://pub.dev/packages/build_test#debugging-web-tests
Note: In order to run the tests this way, you will need to configure them to be compiled (by default we only compile *.browser_test.dart files). You can do this in your build.yaml file, with something like the following:
Almost all of our organization's projects compile only *.browser_test.dart files in order to keep build times low, so enabling this debugging workflow requires temporarily updating build.yaml.
Updating build.yaml, however, invalidates the build cache and can result in long recompile times, especially when debugging dart2js tests. This step can also be confusing for devs who aren't as familiar with build.yaml configuration.
Ideally, the .debug.html files would be able to use the same .browser_test.dart files that pub run build_runner test uses, so that you don't have to mess with the build config.
This is really a problem with package:test and how it does the bootstrapping. Those files are not able to run normally. I don't think that is something that can be easily changed though :/.
I could imagine some other ways of solving this problem (and I do agree its a problem). They aren't super ideal but could work.
.browser_test.debug.dart files that don't actually do bootstrapping, but still only get created if the test claims to support browsers.test/**/*_test.dart files, but it would skip any file that doesn't have a corresponding .browser_test.dart file present.cc @natebosch
I could imagine also doing something like adding logic in .browser_test.dart files to check if they can detect that they are running in an iframe by the test runner. If they are run in that environment they'd keep their existing behavior. If they are running in a different environment they'd run the imported main directly, which should make them behave like the original _test.dart file would.
WDYT?
@natebosch we could investigate doing that yes - I am not sure how hard it would be to do or if it could accidentally end up hiding some other bootstrapping issue.
I just published build_test version 1.3.0 which should make the debug.html file work by default without enabling compilation for the _test.dart files. Please let us know if it doesn't work for you.
Most helpful comment
I could imagine also doing something like adding logic in
.browser_test.dartfiles to check if they can detect that they are running in an iframe by the test runner. If they are run in that environment they'd keep their existing behavior. If they are running in a different environment they'd run the importedmaindirectly, which should make them behave like the original_test.dartfile would.WDYT?