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

Something like expect.snapshot #1214

Open
Chriscbr opened this issue Jan 22, 2023 · 4 comments
Open

Something like expect.snapshot #1214

Chriscbr opened this issue Jan 22, 2023 · 4 comments
Labels
⌨️ cli CLI ✨ enhancement New feature or request

Comments

@Chriscbr
Copy link
Contributor

Chriscbr commented Jan 22, 2023

Community Note

Please vote by adding a 👍 reaction to the issue to help us prioritize.
If you are interested to work on this issue, please leave a comment.

Feature Spec

Starting in Wing v0.x, wing test now saves test snapshots when the matches_snapshot(json) function is used:

bring cloud;

new cloud.Function(inflight () => {
  let data = Json { a: 123, b: "boo" };
  assert(matches_snapshot(data));
}) as "test";

After the first time running the test, an app.w.snap file will be generated containing a sequence of recorded snapshot values associated with each test.

Use Cases

Asserting that outputs generated by user code is as expected.

See https://blog.janestreet.com/the-joy-of-expect-tests/

Implementation Notes

Do snapshots for preflight and inflight require different APIs or mechanisms?

Perhaps we can try implementing this in userland first (using extern)

Component

SDK, Development Environment

@Chriscbr Chriscbr added ✨ enhancement New feature or request ⌨️ cli CLI labels Jan 22, 2023
@Chriscbr Chriscbr mentioned this issue Jan 22, 2023
@github-actions
Copy link

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@github-actions github-actions bot added the Stale label Mar 24, 2023
@staycoolcall911
Copy link
Contributor

I believe this was done by @MarkMcCulloh

@Chriscbr
Copy link
Contributor Author

@staycoolcall911 my apologies - I think the issue might have not been explained well. 😅

I rewrote the description to explain how this would be part of Wing's built-in testing functions - let me know if it makes better sense.

@Chriscbr Chriscbr reopened this Mar 28, 2023
@Chriscbr Chriscbr removed the Stale label Mar 28, 2023
@eladb
Copy link
Contributor

eladb commented Apr 19, 2023

Snapshot format should be a markdown file that shows the output directory in a beautiful and attractive and GitHub readable format.

Credits: @MarkMcCulloh

@eladb eladb changed the title Snapshot tests for wing test Something like expect.snapshot Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⌨️ cli CLI ✨ enhancement New feature or request
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

3 participants