Skip to content
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

Tests fail in browser environment #99

Open
Peetee06 opened this issue Jan 27, 2025 · 2 comments
Open

Tests fail in browser environment #99

Peetee06 opened this issue Jan 27, 2025 · 2 comments

Comments

@Peetee06
Copy link

Description

Tests using spot fail when running them in a browser environment.

Expected behavior

If a test that does not use spot succeeds when passing the --platform chrome flag. The same test refactored to use spot should also succeed.

Actual behavior

Tests that use spot fail with the following error when running them with --platform chrome flag.

Test failed, generating timeline report
  Unsupported operation: Platform._environment
  dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3     throw_
  dart-sdk/lib/_internal/js_dev_runtime/patch/io_patch.dart 279:5                 _environment
  dart-sdk/lib/io/platform_impl.dart 83:17                                        get environment
  dart-sdk/lib/io/platform.dart 177:59                                            get environment
  packages/ci/src/ci.dart.js 21:26                                                get isCI
  packages/spot/src/widgets/wrap.g.dart.js 12107:22                               reportOnError
  dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50              <fn>

Steps to reproduce

  1. Clone https://github.com/peetee06/spot_browser_issue
  2. Run flutter test --platform chrome
@passsy
Copy link
Owner

passsy commented Jan 27, 2025

You're correct.

I just tested it. The following features do not work on web:

  • timeline (can't write HTML report to disk)
  • screenshots (can't write files to disk)
  • font loading (can't load font)

I might find workarounds but not in the short-term.

What's your reason for executing your tests in chrome instead of the Dart VM?


Since you might have some experience with running tests in chrome: Would you rather have await loadAppFonts() crash on web or do nothing on web (with warning in the console)?

@Peetee06
Copy link
Author

One example was that we are using flutter_pdfview to view PDFs. We ran into an issue, because that package only works on mobile platform. So we used a different code path using if (kIsWeb) to open the url via url_launcher on web instead.

Because we are already using spot everywhere else, we wanted to use it here as well, also for the nicer syntax.


We skip await loadAppFonts() in our tests, so passing with a warning would be best. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants