Skip to content

Commit

Permalink
Fix Error printout for protocol-response tests (smithy-lang#657)
Browse files Browse the repository at this point in the history
* Fix broken reference to `fail()` after jest-upgrade

Jest versions >= 27 replace jest-jasmine2 with jest-circus, which does
not have an implementation for the `fail()` method, but still has
the method stub defined in the Jest type-defs. This change implements
the `fail()` method in protocol test suites, and adjusts the thrown
message to actually state the error, instead of just `err`.

* Remove interpolation of error in response tests

When writing strings with newlines and interpolation, code can get mangled
and won't compile. This change makes the error printout a single-line and not
interpolated.
  • Loading branch information
haydenbaker authored and srchase committed Mar 17, 2023
1 parent 6d3232c commit acd6203
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ private void generateResponseTest(OperationShape operation, HttpResponseTestCase
writer.write("try {\n"
+ " r = await client.send(command);\n"
+ "} catch (err) {\n"
+ " fail('Expected a valid response to be returned, got:\n\n `${err}`');\n"
+ " fail(\"Expected a valid response to be returned, got \" + err);\n"
+ " return;\n"
+ "}");
writeResponseAssertions(operation, testCase);
Expand Down

0 comments on commit acd6203

Please sign in to comment.