-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
test(gradle): stop mocking the file system #5826
Conversation
lib/manager/gradle/index.spec.ts
Outdated
const replacingSerializer = ( | ||
search: string, | ||
replacement: string | ||
): jest.SnapshotSerializerPlugin => ({ | ||
test: value => typeof value === 'string' && value.includes(search), | ||
serialize: (val, config, indent, depth, refs, printer) => { | ||
const replaced = (val as string).replace(search, replacement); | ||
return printer(replaced, config, indent, depth, refs); | ||
}, | ||
}); | ||
|
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.
This is a great idea. Could you extract it to test/utils.ts
, as there are quite a few places we mock fs
to get consistent path names, and this is a much better approach.
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.
Yes, please move replacingSerializer
to test/utils
Done |
🎉 This PR is included in version 19.192.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Given the mistake I made in #5806, I went ahead and replaced the file system mocking in the gradle tests with real file system accesses. From my point of view, the less we mock, the higher the probability that we find regressions. I could find no good reasons to mock the file system here. The mocking also depended on the precise
fs
functions the code called, and on the order of those calls.Even though I think I have good reasons for this change, I realise that it is also a question of philosophy. So feel free to close this pull request if you prefer to keep the file system mocks.