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

feat(sdk): expect module with assertions for testing #3976

Merged
merged 47 commits into from
Nov 2, 2023
Merged

Conversation

skorfmann
Copy link
Contributor

@skorfmann skorfmann commented Aug 26, 2023

After some back and forth we settled on using expect as the module name. Mostly for the reason that assert is a builtin function already and would cause naming conflicts. The pull request discussions for more details.

Checklist

  • Title matches Winglang's style guide
  • Description explains motivation and solution
  • Tests added (always)
  • Docs updated (only required for features)
  • Added pr/e2e-full label if this feature requires end-to-end testing

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

An initial stab at #3918 to introduce test assertions in a testing module

This renames the pre-existing `testing` module to `simulatorTesting`, but
there are likely better names.

Thoughts?
@monadabot
Copy link
Contributor

monadabot commented Aug 31, 2023

Console preview environment is available at https://wing-console-pr-3976.fly.dev 🚀

Last Updated (UTC) 2023-11-02 19:39

@skorfmann
Copy link
Contributor Author

Since generic function overloading is not working at the moment, I'm curious in which direction assertions should go. Thoughts?

1. Pure Functions

All possible matchers at the same level, no scoping.

assertStrEqual("a", "a")
assertStrIncludes("asflkasf", "asflkasfasflkasf")
...
assertNumEqual(1,1)
...
assertFnThrows(fn, new Error())

2. Chained Objects

Type specific high level "entry point" functions (e.g. expectStr) which return an object with all possible matchers for that specific type.

expectStr("a").toEqual("a")
expectStr("asflkasfasflkasf").toInclude("asflkasf")
...
expectNum(1).toEqual(1)
...
expectFn(fn).toThrow(new Error())

@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Nov 1, 2023
@skorfmann skorfmann changed the title feat(sdk): testing module feat(sdk): expect module with builtin assertions for testing Nov 1, 2023
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

This is looking great.

@eladb eladb changed the title feat(sdk): expect module with builtin assertions for testing feat(sdk): expect module with assertions for testing Nov 2, 2023
monadabot and others added 2 commits November 2, 2023 21:29
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

SHIP IT

@skorfmann skorfmann removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Nov 2, 2023
Copy link
Contributor

mergify bot commented Nov 2, 2023

Thanks for contributing, @skorfmann! This PR will now be added to the merge queue, or immediately merged if 3918-testing-module is up-to-date with main and the queue is empty.

mergify bot added a commit that referenced this pull request Nov 2, 2023
@mergify mergify bot merged commit d9c1281 into main Nov 2, 2023
15 checks passed
@mergify mergify bot deleted the 3918-testing-module branch November 2, 2023 20:32
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.44.0.

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.

8 participants