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

chore: migrate more modules to jest #16533

Merged
merged 3 commits into from
Sep 21, 2021
Merged

chore: migrate more modules to jest #16533

merged 3 commits into from
Sep 21, 2021

Conversation

kaizencc
Copy link
Contributor

Migrates aws-ecs-patterns and aws-sqs to jest.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Sep 17, 2021

@kaizencc kaizencc requested a review from nija-at September 17, 2021 17:54
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Sep 17, 2021
// THEN - stack does not contain a LaunchConfiguration
const template = SynthUtils.synthesize(stack, { skipValidation: true });
expect(template).not.toHaveResource('AWS::AutoScaling::LaunchConfiguration');
expect(() => SynthUtils.synthesize(stack)).toThrow();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nija-at I'd like a second pair of eyes on this test (there are 2 other tests with the same pattern as well). It is comparable to this test in nodeunit:

// THEN - stack does not contain a LaunchConfiguration
expect(stack, true).notTo(haveResource('AWS::AutoScaling::LaunchConfiguration'));
test.throws(() => expect(stack));

The issue in question is the use of expect(stack, true) as the true refers to setting skipValidation=true. Without it, the test returns a validation error and we cannot check if the stack contains LaunchConfiguration or not. Since the Jest expect() function does not allow this, I dove in and found SynthUtils.synthesize exposes such an option.

I'm not sure if this is the best way to go about this so I wanted to bring it to your attention.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Kaizen. This is fine for now.

When we migrate this module to 'assertions', we will need to make the validation succeed.

@mergify
Copy link
Contributor

mergify bot commented Sep 21, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 2628510
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 3a486c4 into aws:master Sep 21, 2021
@mergify
Copy link
Contributor

mergify bot commented Sep 21, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@kaizencc kaizencc deleted the jest-migrate-2 branch October 13, 2021 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants