dwyl / learn-flutter

🦋 Learn how to use Flutter to Build Cross-platform Native Mobile Apps
https://flutter.dev
GNU General Public License v2.0
87 stars 8 forks source link

Running test 'Check if item list is rendered' fails when following README guide #100

Open Hako-Ben opened 3 months ago

Hako-Ben commented 3 months ago

I followed the README guide word for word and faced an error when implementing section 6.2 Widget testing.

VSCode debug console output: The test description was: Check if item list is rendered

Warning: At least one test in this suite creates an HttpClient. When running a test suite that uses TestWidgetsFlutterBinding, all HTTP requests will return status code 400, and no network request will actually be made. Any test expecting a real network connection and status code will fail. To test code that needs an HttpClient, provide your own HttpClient implementation to the code under test, so that your test can consistently provide a testable response to the code under test. ✖ Check if item list is rendered

Exited (1).

Issue: was caused by this line of code futureTodosList = TodoService().getTodos();

Solution: update the README section 6.2 Widget testing to prompt the user(s) to update the line futureTodosList = TodoService().getTodos(); to futureTodosList = widget.todoService.getTodos();