fzyzcjy / flutter_convenient_test

Write and debug tests easily, with full action history, time travel, screenshots, rapid re-execution, video records, interactivity, isolation and more
pub.dev/packages/convenient_test
MIT License
479 stars 43 forks source link

Web Support #283

Closed rob-mur closed 1 year ago

rob-mur commented 1 year ago

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.

welcome[bot] commented 1 year ago

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

fzyzcjy commented 1 year ago

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

fzyzcjy commented 1 year ago

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

Looking forward to your PR :)

rob-mur commented 1 year ago

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.

fzyzcjy commented 1 year ago

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)

rob-mur commented 1 year ago

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:

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

fzyzcjy commented 1 year ago

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
rob-mur commented 1 year ago

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)

fzyzcjy commented 1 year ago

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

rob-mur commented 1 year ago

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!

stale[bot] commented 1 year ago

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.

github-actions[bot] commented 1 year ago

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.