File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ release type : minor
3+ social_messages :
4+ x : >-
5+ {project_name} {version} is out! This release adds richer verbose output
6+ to `assert_no_errors`, including full response error details for easier
7+ debugging. 🍓 https://strawberry.rocks/release/{version}
8+ linkedin: >-
9+ {project_name} {version} is out. This release adds richer verbose output
10+ to `assert_no_errors`, including full response error details for easier
11+ debugging.
12+ ---
13+
14+ This release adds richer verbose output to ` assert_no_errors ` . When GraphQL
15+ errors are detected, the assertion now includes full error details, making it
16+ easier to debug failing tests.
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ async def query(
2727
2828 if assert_no_errors :
2929 assert resp .status == 200
30- assert response .errors is None
30+ assert response .errors is None , response . errors
3131
3232 return response
3333
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ def query(
5353 )
5454
5555 if assert_no_errors :
56- assert response .errors is None
56+ assert response .errors is None , response . errors
5757
5858 return response
5959
Original file line number Diff line number Diff line change 1+ """Test that assert_no_errors includes response.errors in the AssertionError message."""
2+
13from contextlib import nullcontext
24
35import pytest
46
57from strawberry .utils .await_maybe import await_maybe
68
9+ QUERY_TO_NON_EXISTENT_FIELD = "{ nonExistentField { id } }"
10+
11+ NON_EXISTENT_FIELD_ERRORS = [
12+ {
13+ "message" : "Cannot query field 'nonExistentField' on type 'Query'." ,
14+ "locations" : [{"line" : 1 , "column" : 3 }],
15+ }
16+ ]
17+
718
819@pytest .mark .parametrize (
920 ("assert_no_errors" , "expectation" ),
@@ -18,3 +29,10 @@ async def test_query_with_assert_no_errors_option(
1829 await await_maybe (
1930 graphql_client .query (query , assert_no_errors = assert_no_errors )
2031 )
32+
33+
34+ async def test_assert_no_errors_includes_response_errors_in_message (graphql_client ):
35+ with pytest .raises (AssertionError ) as exc_info :
36+ await await_maybe (graphql_client .query (QUERY_TO_NON_EXISTENT_FIELD ))
37+
38+ assert exc_info .value .args [0 ] == NON_EXISTENT_FIELD_ERRORS
You can’t perform that action at this time.
0 commit comments