flutter_convenient_test icon indicating copy to clipboard operation
flutter_convenient_test copied to clipboard

Web Support

Open rob-mur opened this issue 3 years ago • 5 comments

Is your feature request related to a problem? Please describe. Currently (as far as I know) this tool doesn't work with web builds - which would be cool functionality to have. The current error message if you just tried to do this today is:

/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/convenient_test_dev-1.2.0/lib/src/functions/core.dart:138:75: Error: The getter 'basedir' isn't defined for the class 'LocalFileComparator'.
 - 'LocalFileComparator' is from 'package:flutter_test/src/_goldens_web.dart' ('/C:/flutter/flutter/packages/flutter_test/lib/src/_goldens_web.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'basedir'.
      'comparator.basedir=${(goldenFileComparator as LocalFileComparator).basedir}');

Describe the solution you'd like Ideally something similar to what exists for other platforms (just flutter run with some args), although remains to be seen if its possible with web.

Describe alternatives you've considered The alternative would be to just run your integration tests on say a large format desktop platform (windows/mac/linux) and hope that there's nothing web specific that breaks your app. Honestly this is probably fine, but would be cool to investigate this to see.

I haven't yet read through your contribution docs/general design but will take a look when I next get some time to see how this is approached.

rob-mur avatar Oct 02 '22 09:10 rob-mur

Hi! Thanks for opening your first issue here! :smile:

welcome[bot] avatar Oct 02 '22 09:10 welcome[bot]

For future readers: https://github.com/fzyzcjy/flutter_rust_bridge/issues/760#issuecomment-1264589733

fzyzcjy avatar Oct 02 '22 11:10 fzyzcjy

As mentioned earlier, you may do this by disabling or porting some functionalities.

Looking forward to your PR :)

fzyzcjy avatar Oct 02 '22 11:10 fzyzcjy

Done some more research and the current culprit seems to be that the GoldenComparator is unsupported for Web. I noticed this from the documentation of goldens_web in flutter and seems to track from here - there seems to be some difficulty getting consistent screenshots in flutter web.

The file in question can be seen in flutter\packages\flutter_test\lib\src_goldens_web.dart and the telling docstring is the following description of LocalFileComparator

/// An unsupported [GoldenFileComparator] that exists for API compatibility.
class LocalFileComparator extends GoldenFileComparator {

I'm assuming that your library heavily uses these comparators for checking the correctness of widgets? If that is the case then I think this issue would be blocked by that upstream problem.

rob-mur avatar Oct 02 '22 16:10 rob-mur

That is optional feature. If you never compare goldens when you use the convenient_test then it is no problem to remove it :) (But I personally use it a lot)

fzyzcjy avatar Oct 02 '22 22:10 fzyzcjy

As you'll see in my initial investigation above, it looks like the only supported way to run integration tests on flutter web at the moment is through flutter drive and something like ChromeDriver. This seems like a pretty big obstacle at the moment to getting this working.

I think our current options to recommend are either:

  • Just do your UI/e2e tests in something like windows/android and assume it carries over to web
  • Use only the base integration test library and hence lose the benefit of this tool

Let me know if you have other ideas - you are much more experienced than I am.

rob-mur avatar Oct 22 '22 21:10 rob-mur

This tool is based on integration test. So maybe we can do this:

  1. Use it normally in android/ios
  2. In Web, reduce some features of flutter_convenient_test, then run this reduced version

fzyzcjy avatar Oct 22 '22 22:10 fzyzcjy

So I think the problem is that only flutter drive is supported, which acts a bit like flutter test in that is just runs through the tests once with no way to communicate with the manager.

Potentially the manager could have some option added that allows it to call this command in a directory to get a visual report of the tests passing/failing.

I think you would still need ChromeDriver however.

Currently if you did flutter run, there's an error about frames being painted, even with goldens removed. You can check it out in my fork if you like - just need to make sure you're on master version of flutter (doesn't work at all on stable, see issue in the fork)

rob-mur avatar Oct 23 '22 07:10 rob-mur

IMHO convenient_test consists of several parts. One part is that manager drives worker, but that part may be removed for web.

fzyzcjy avatar Oct 23 '22 07:10 fzyzcjy

That's a good idea. We could try to at least keep the same code as used for the other devides' tests (or as close as possible), that can then be run with flutter drive.

I'll take a look at that when I'm next working on it!

rob-mur avatar Oct 23 '22 07:10 rob-mur

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 22 '22 23:12 stale[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.

github-actions[bot] avatar Jan 13 '23 00:01 github-actions[bot]