Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken reference to fail() after jest-upgrade #645

Merged
merged 1 commit into from
Dec 12, 2022

Conversation

haydenbaker
Copy link
Contributor

Description of changes:

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.

For more information, see DefinitelyTyped maintainer discussion

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

Testing
Run the protocol test suite after making changes and running the codegen

Before changes:

   Ec2QueryDateTimeWithNegativeOffset:Response

    ReferenceError: fail is not defined

      184 |     r = await client.send(command);
      185 |   } catch (err) {
    > 186 |     fail("Expected a valid response to be returned, got err.");
          |     ^
      187 |     return;
      188 |   }
      189 |   expect(r["$metadata"].httpStatusCode).toBe(200);

      at test/functional/ec2query.spec.ts:186:5
          at Generator.throw (<anonymous>)
      at rejected (../../node_modules/tslib/tslib.js:115:69)

After changes:

   Ec2QueryDateTimeWithNegativeOffset:Response

    Expected a valid response to be returned, got err:

    TypeError: Invalid RFC-3339 date-time value

      162 |  */
      163 | function fail(error?: any): never {
    > 164 |   throw new Error(error);
          |         ^
      165 | }
      166 |
      167 | /**

      at fail (test/functional/ec2query.spec.ts:164:9)
      at test/functional/ec2query.spec.ts:194:5
          at Generator.throw (<anonymous>)
      at rejected (../../node_modules/tslib/tslib.js:115:69)

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`.
@haydenbaker haydenbaker requested a review from a team as a code owner November 22, 2022 16:02
@haydenbaker haydenbaker requested a review from srchase December 9, 2022 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants