network_image_mock icon indicating copy to clipboard operation
network_image_mock copied to clipboard

tests fail in github actions

Open Dan-Y-Ko opened this issue 2 years ago • 0 comments

Hello, my tests pass when I run them locally (macos) but fail when run through github actions. I believe it is related to mocking network images in the tests but if not I apologize.

I have tried switching the os gh actions builds on to macos and it does succeed, so it seems to be some kind of issue with ubuntu? I'm not sure the reason for it failing in that environment.

Here's the logs:

00:11 +1: book_models_book_detail_test_dart Book model instantiates properly
00:11 +2: ...odels_book_detail_test_dart Book model toString returns expected string
00:11 +3: ..._models_book_detail_test_dart Book model object comparison is supported
00:11 +4: ...l_page_test_dart book detail page Loading is rendered on loading status
00:11 +5: ...age_test_dart book detail page Error Screen is rendered on error status
00:11 +6: ...detail_page_test_dart book detail page renders nothing on initial state
00:11 +7: ...st_dart book detail page Book Detail Page is rendered on success status
00:11 +8: ...detail_book_detail_event_test_dart GetBookDetailEvent props are correct
00:11 +9: ..._book_detail_event_test_dart GetBookDetailEvent supports value equality
00:12 +10: ..._widgets_search_input_test_dart search input triggeres fetch on submit

══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
The following NetworkImageLoadException was thrown resolving an image codec:
HTTP request failed, statusCode: 400,
file:///home/runner/work/chingu_bookfinder_flutter/chingu_bookfinder_flutter/someUrl

When the exception was thrown, this was the stack:
#0      NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:97:9)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

Image provider: NetworkImage("someUrl", scale: 1.0)
Image key: NetworkImage("someUrl", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════════════════════════

Test failed. See exception logs above.
The test description was: navigates to book detail page on tap of view details button
00:12 +11: widgets_custom_circular_button_test_dart button callback gets called
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.


book_widgets_book_list_widget_test_dart book detail card navigates to book detail page on tap of view details button /home/runner/work/chingu_bookfinder_flutter/chingu_bookfinder_flutter/test/.test_runner.dart (FAILED)

══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
The following NetworkImageLoadException was thrown resolving an image codec:
HTTP request failed, statusCode: 400,
file:///home/runner/work/chingu_bookfinder_flutter/chingu_bookfinder_flutter/someUrl

When the exception was thrown, this was the stack:
#0      NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:97:9)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

Image provider: NetworkImage("someUrl", scale: 1.0)
Image key: NetworkImage("someUrl", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════════════════════════

Test failed. See exception logs above.
The test description was: renders card properly

book_widgets_book_list_widget_test_dart book detail card renders card properly /home/runner/work/chingu_bookfinder_flutter/chingu_bookfinder_flutter/test/.test_runner.dart (FAILED)
00:12 +11 -1: ...il card navigates to book detail page on tap of view details button
00:12 +11 -2: ...s_book_list_widget_test_dart book detail card renders card properly
00:12 +12 -2: book_models_book_test_dart Book model instantiates properly
00:12 +13 -2: ...k_models_book_test_dart Book model toString returns expected string
00:12 +14 -2: ...ook_models_book_test_dart Book model object comparison is supported
00:12 +15 -2: ...loc_google_auth_google_auth_state_test_dart supports value equality
00:12 +16 -2: ..._dart copyWith returns the same object if no arguments are provided
00:12 +17 -2: auth_bloc_google_auth_google_auth_state_test_dart Props are correct
00:12 +18 -2: auth_service_google_auth_test_dart sign out is called succesfully
00:12 +19 -2: ...rt sign in returns instance of sign in with google failure on error
00:12 +20 -2: auth_service_google_auth_test_dart sign in is called succesfully
00:12 +21 -2: ...ge_test_dart Book List Page Book List is rendered on success status
00:12 +22 -2: ...ok_view_book_page_test_dart Book List Page search input is rendered
00:12 +23 -2: ..._test_dart Book List Page Clicking on sign out button logs user out
00:12 +[24](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:25) -2: ...page_test_dart Book List Page Loading is rendered on loading status
00:12 +[25](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:26) -2: ...t_dart Book List Page Book List Empty is rendered on initial status
00:12 +[26](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:27) -2: ...e_test_dart Book List Page Error Screen is rendered on error status
00:12 +[27](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:28) -2: ...book bloc GetBookDetailEvent emits failure status when error occurs
00:12 +[28](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:29) -2: ...sful fetch and 
          when GetBookDetailEvent is added

══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
The following NetworkImageLoadException was thrown resolving an image codec:
HTTP request failed, statusCode: 400,
file:///home/runner/work/chingu_bookfinder_flutter/chingu_bookfinder_flutter/someUrl

00:12 +[29](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:30) -2: ...rt book detail bloc book bloc constructor has correct initial state
When the exception was thrown, this was the stack:
#0      NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:97:9)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

Image provider: NetworkImage("someUrl", scale: 1.0)
Image key: NetworkImage("someUrl", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════════════════════════

Test failed. See exception logs above.
The test description was: renders card properly

book_widgets_book_detail_card_test_dart book detail card renders card properly /home/runner/work/chingu_bookfinder_flutter/chingu_bookfinder_flutter/test/.test_runner.dart (FAILED)
00:12 +29 -3: ...s_book_detail_card_test_dart book detail card renders card properly
00:12 +[30](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:31) -3: ...ok_list_book_list_state_test_dart BookState supports value equality
00:12 +[31](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:32) -3: ...State copyWith returns the same object if no arguments are provided
00:12 +[32](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:33) -3: ...loc_book_list_book_list_state_test_dart BookState Props are correct
00:12 +[33](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:34) -3: ...book_list_event_test_dart BookEvent GetBooksEvent props are correct
00:12 +[34](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:35) -3: ...ist_event_test_dart BookEvent GetBooksEvent supports value equality
00:12 +[35](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:36) -3: ...dart book bloc GetBooksEvent emits failure status when error occurs
00:12 +[36](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:37) -3: ...ful fetch and books 
          when GetBooksEvent is added
00:12 +[37](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:38) -3: ...list_bloc_test_dart book bloc constructor has correct initial state
00:12 +[38](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:39) -3: ...constructor instantiates internal GoogleApiClient when not injected
00:12 +[39](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:40) -3: ...t_dart Book Service getBook properly throws when there is exception
00:12 +[40](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:41) -3: ...k_service_test_dart Book Service getBook returns correct Book model
00:13 +[41](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:42) -3: ..._dart Book Service getBooks properly throws when there is exception
00:13 +[42](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:43) -3: ..._service_test_dart Book Service getBooks returns correct Book model
00:13 +[43](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:44) -3: ...th_google_auth_bloc_test_dart constructor has correct initial state
00:13 +[44](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:45) -3: ..._bloc_test_dart SignOutEvent emits failure status when error occurs
00:13 +[45](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:46) -3: ...out is called and
          succcess status if successful
00:13 +[46](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:47) -3: ..._test_dart GoogleSignInEvent emits failure status when error occurs
00:13 +[47](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:48) -3: ...n in is called and
          succcess status if successful
00:13 +[48](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:49) -3: ...book_detail_state_test_dart BookDetailState supports value equality
00:13 +[49](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:50) -3: ...State copyWith returns the same object if no arguments are provided
00:13 +[50](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:51) -3: ...etail_book_detail_state_test_dart BookDetailState Props are correct
00:13 +50 -3: Some tests failed.

Failing Tests:

Error: OR] ...est description was: navigates to book detail page on tap of view details button

Error: OR] ...ailed. See exception logs above. The test description was: renders card properly

Error: OR] ...ailed. See exception logs above. The test description was: renders card properly

Error: Process completed with exit code [69](https://github.com/Dan-Y-Ko/chingu_bookfinder_flutter/runs/7816069697?check_suite_focus=true#step:7:70).

Dan-Y-Ko avatar Aug 13 '22 02:08 Dan-Y-Ko