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

Use toMatchSnapshot inside expectMetricsJson #3359

Closed
edi9999 opened this issue Jan 17, 2022 · 6 comments
Closed

Use toMatchSnapshot inside expectMetricsJson #3359

edi9999 opened this issue Jan 17, 2022 · 6 comments
Labels
🔧 Maintenance Maintenance issue

Comments

@edi9999
Copy link
Contributor

edi9999 commented Jan 17, 2022

Is your maintenance request related to a problem? Please describe.

When changing the number of generated mutators, all expectMetricsJson expectations need to be manually changed.

Describe the solution you'd like

I've tried to add .toMatchSnapshot() instead, so that it would instead be possible to "regenerate" all snapshot files of the metrics.

Describe alternatives you've considered

Haven't found other ideas

Additional context

Copy/Pasting the mocha output was quite tedious on my Pull Request, and took probably more time than developping the feature itself.

@edi9999 edi9999 added the 🔧 Maintenance Maintenance issue label Jan 17, 2022
@edi9999
Copy link
Contributor Author

edi9999 commented Jan 17, 2022

The ideas comes from this thread : #3346 (comment)

@nicojs
Copy link
Member

nicojs commented Jan 17, 2022

Great idea.

I do think that using snapshots can result in lazy developers (me included) that update the snapshots without thinking too hard about it, resulting in bugs. But that is more something we will need to keep an eye on.

Q: Do you want to create a custom matcher yourself? Or do you want to use chai-jest-snapshot, which we are already using in the instrumenter integration tests. Maybe developing it yourself is easier.

@edi9999
Copy link
Contributor Author

edi9999 commented Jan 17, 2022

I do think that using snapshots can result in lazy developers

I would argue the contrary, the fact that when you need to update these tests takes a long "human" time with very low value makes the task annoying and since you've already given X amout of time on this task, you take less time in the "analyzing" part.

Q: Do you want to create a custom matcher yourself

I think creating a custom matcher would be easier, should I place this logic somewhere in the "helpers" directory and include it from each test ?

If I understood correctly, all e2e tests use mocha for the verification of the metrics, is that correct ?

@nicojs
Copy link
Member

nicojs commented Jan 17, 2022

Yes, we use mocha in the various verify directories. It doesn't nessesarily have to be a chai matcher, I would also be happy with this:

await expectMetricsJsonEqualsSnapshot()

@edi9999
Copy link
Contributor Author

edi9999 commented Jan 17, 2022

I tried to add chai-jest-snapshot and it turns out it wasn't that complex after all.

@nicojs
Copy link
Member

nicojs commented Jan 26, 2022

Fixed with #3360

@nicojs nicojs closed this as completed Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 Maintenance Maintenance issue
Projects
None yet
Development

No branches or pull requests

2 participants