-
Notifications
You must be signed in to change notification settings - Fork 218
[ERROR] Deferred library load doesn't work inside browser tests #2088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It is possible to disable deferred loading on I don't think that |
Thanks so much for filing this issue! I've transferred it to the package:test github issue tracker, since this appears to be an issue there. Sometimes it's valuable to be able to write tests that use deferred loading, but I agree it can often be helpful to just disable it. There is a dart2js flag to disable the split: |
According to https://pub.dev/packages/test#compiler-flags, it seems possible to pass this flag when invoking the test runner. Does your test work if you pass |
Thanks for the reply. I have tested it with I have updated the project and added an extra CI workflow job. Now you can see that the test with the default configuration ( https://github.com/gmpassos/deferred_lib_issue/actions/runs/6089670634/job/16522963991
|
Would there be a downside to us passing that flag? Is it possible programs could be using deferred libraries incorrectly but their test would pass since we disabled the split? |
The flag is designed to preserve semantics, modulo loading files from the network, so the only downside is that it's loading more code upfront that may not be necessary. It's rare that developers want to test the actual network loading in their unit tests, but that's the other piece that would be missing from using the flag. I think using the flag makes sense, unless you think the alternative is simple to support (e.g. to serve all the .js files together) |
The flag would be easier, but I am sure we could do it either way. |
You just need to make 'Dart2JsCompilerPool.compile' to return the output files. Then you can use this list to map the files to serve. |
Dart2js doesn't actually tell you all the output files, but yeah we can likely just glob for them, which I plan to try first. |
When
dart2js
is used by the package test it's notable to serve the
...part.js
file.You can reproduce the bug running the test of this repository:
https://github.com/gmpassos/deferred_lib_issue
dart test -p chrome
Error output:
Dart Version:
The issue can be fixed at:
https://github.com/dart-lang/test/blob/master/pkgs/test/lib/src/runner/browser/platform.dart
The text was updated successfully, but these errors were encountered: