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

[WIP] custom jest output matchers #868

Draft
wants to merge 1 commit into
base: justin/tests-aws-typescript
Choose a base branch
from

Conversation

julienp
Copy link
Contributor

@julienp julienp commented Dec 18, 2024

This shows a custom jest test matchers that know about Outputs.

expect(...).apply(applyFn) takes a callback that's meant to work like Output.apply. Internally it translates to a promise for jest so we don't have to deal with done().

expect(...).toEqualOutputOf(...) can be used to easily check the resolved value of an output.

We could ship these matchers in a @pulumi/jest-matchers library.

Example output for failures:

(line numbers are wrong, but this is unrelated to the PR)

Screenshot 2024-12-18 at 17 23 51

expect(tags).toHaveProperty("Name");
});
it("must have the right tags", async () => {
await (expect(infra.bucket.tags) as any).toEqualOutputOf({ "Name": "My bucket oops" })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't extend the expect type to know about our matchers, with that we won't need the cast to any here.

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.

1 participant