-
Notifications
You must be signed in to change notification settings - Fork 1
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
[no-Jira] Make enum mocking deterministic #1155
Conversation
Bundle sizes [mpdx-react]Compared against 121cd06 No significant changes found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you've altered the yarn.lock file and files inside .yarn. Was there no way to alter the package.json file to do these changes?
graphql-ergonomock is an unmaintained project (no commits in 3 years and no recent responses on bug reports), or I'd submit an upstream PR. That's why I'm making the fix to that package as a yarn patch. I can vendor the package and copy all the files into our project so that we can make changes freely if you'd prefer. I think that publishing a fork to npm is probably more effort than it's worth. |
@dr-bizz Do you have any more thoughts on this? @wrandall22 Maybe you have input too? For perspective, there are two patches we've made to graphql-ergonomock. One to support graphql v15, and this one to fix a bug with deterministic mocking. I feel like that's acceptable for a patch and if we have to change anything else in the future, maybe we consider vendoring the package. |
That is probably fine. I agree that if we keep making changes we should fork the repo. |
@canac Also, what if the original package is updated in the future? If you use a fork, you can merge those updates into your forked version. This helps keep your version in sync with any upstream improvements. |
@dr-bizz One challenge in this case is that our application doesn't consume the raw source code from the graphql-ergonomock package, we consume the published build files. So it's not as simple as forking the repo and making the package a git dependency in This complexity is why I suggested vendoring the code since it is a small package (11 files including test files). That will let us run our JSX and TypeScript transforms on the package code. We won't get future updates without manually pulling them in. But the package shows all signs of being abandoned, so I'm not convinced it's worth doing extra work now just in case the upstream repo becomes active again. |
Yes, you will need to create an NPM package for this forked repo. This is how I've done it in the past. onesky-utils is a good example. I created Cru's own version of the code when the package wasn't updated and I needed to add a fix. They have since updated their app, so I could migrate God Tools back onto their version and close this one. |
I have invited you to CruGlobal NPM organisation |
b170320
to
887daa4
Compare
887daa4
to
8c19c14
Compare
@@ -144,7 +144,7 @@ | |||
"eslint-plugin-react": "^7.31.8", | |||
"full-icu": "^1.5.0", | |||
"glob": "^8.0.3", | |||
"graphql-ergonomock": "^1.2.0", | |||
"graphql-ergonomock": "npm:@cruglobal/graphql-ergonomock@^1.2.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured out that we can use this syntax to use our fork without having to update all of our imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know this was a feature. This is a great way to add it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Thank you for showing me "npm:{package}@{version}"
@@ -144,7 +144,7 @@ | |||
"eslint-plugin-react": "^7.31.8", | |||
"full-icu": "^1.5.0", | |||
"glob": "^8.0.3", | |||
"graphql-ergonomock": "^1.2.0", | |||
"graphql-ergonomock": "npm:@cruglobal/graphql-ergonomock@^1.2.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know this was a feature. This is a great way to add it!
Description
<GqlMockedProvider>
was picking a random value for enums that could vary between tests. That was a source of flaky tests. This PR switches to using our new CruGlobal fork, which contains the stable random enum fix in CruGlobal/graphql-ergonomock#1.Checklist: