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: performance results file validation #216

Merged
merged 17 commits into from
Oct 20, 2022

Conversation

ShaswatPrabhat
Copy link
Contributor

Validate performance results files input to compare package using zod

@changeset-bot
Copy link

changeset-bot bot commented Oct 8, 2022

🦋 Changeset detected

Latest commit: fa11aee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
reassure Minor
@callstack/reassure-cli Minor
@callstack/reassure-compare Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

ShaswatPrabhat and others added 3 commits October 18, 2022 16:16
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
Copy link
Member

@mdjastrzebski mdjastrzebski left a comment

Choose a reason for hiding this comment

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

The code looks pretty good 👍🏻 I've added some comments about improving the code organisation a bit more.

I think we should also add some basic unit tests that would load a couple of hardcode performance files from disk and check that they match the expected output. The goal here is not not test Zod library, as it probably has it's own tests but rather to make sure that we are still able to run load typical performance results files. I would go with four input files: one with header, one without header, one with incorrect JSON, last one with duplicate entries.

packages/reassure-compare/src/utils/validate.ts Outdated Show resolved Hide resolved
packages/reassure-compare/src/compare.ts Outdated Show resolved Hide resolved
packages/reassure-compare/src/utils/validate.ts Outdated Show resolved Hide resolved
@ShaswatPrabhat
Copy link
Contributor Author

Have resolved all of the code feedback @mdjastrzebski .

Will get started on unit testing.

@ShaswatPrabhat
Copy link
Contributor Author

@mdjastrzebski will it be a good idea to export loadFile from compare.ts and write tests against it then?

Not very keen on writing tests for the full compare method.

Another approach can be to write tests for the exported methods from validate.ts file.

Please suggest.

@mdjastrzebski
Copy link
Member

mdjastrzebski commented Oct 18, 2022

@ShaswatPrabhat exporting loadFile from file is ok, just do not add it to index.ts exports so that the whole package does not export it.

Also pls do not make the test overly complicated, as simple test fields with/without header row and 2-3 entries should be enough. Then you can put assertions on metadata, total number of entries and values from 1-2 entries per file. In case of single failing test just check the error message.

BTW the code looks really good now, I've added some minor comments but I am very happy with the results 🚀

@ShaswatPrabhat
Copy link
Contributor Author

Have added 2 basic snapshot tests based on jest and initial setup.

Please let me know if this is similar to what you have in mind @mdjastrzebski

As the errors and success are both too large hence have snapshotted them

Copy link
Member

@mdjastrzebski mdjastrzebski left a comment

Choose a reason for hiding this comment

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

@ShaswatPrabhat Looks good, I plan on merging it tomorrow. Thank you for contributing this feature.

@mdjastrzebski mdjastrzebski changed the title Feat/perf file validation feat: performance results file validation Oct 20, 2022
Copy link
Member

@mdjastrzebski mdjastrzebski left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for contributing this feature @ShaswatPrabhat 🚀

@mdjastrzebski mdjastrzebski merged commit 3a180f2 into callstack:main Oct 20, 2022
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.

None yet

2 participants