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

tests(smoke): add tests for report-assert.js #14138

Merged
merged 4 commits into from
Jun 22, 2022
Merged

Conversation

connorjclark
Copy link
Collaborator

Adding some tests here, will help with #14128

@connorjclark connorjclark requested a review from a team as a code owner June 17, 2022 00:51
@connorjclark connorjclark requested review from adamraine and removed request for a team June 17, 2022 00:51
@brendankenny
Copy link
Member

This is another instance of an old discussion, but the report assertions are simple and compose simply and so would lend themselves to regular unit tests very well: (1) Do these assertions work, then (2) Do these assertions compose.

Snapshot tests can be good for complicated data and especially for complicated data that's expected to change often, but they come at the price of being verbose and having a low signal/noise ratio. It's difficult to tell what a test is for (especially when it fails on something that it's ostensibly not for), and there's a ton of input and a ton of output to wade through to figure that out.

The benefit of the assertions being written (relatively) generally is that an entire LHR isn't needed to test if _includes is working. It just needs needs the single entry, which also means it's simple (and short) to test multiple variations of it.


describe('findDifference', () => {
const testCases = {
'works (trivial passing)': {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@brendankenny how's this?

return text
.replace(/\x1B.*?m/g, '')
.replace(/\x1b.*?m/g, '')
.replace(/[✘×]/g, 'X')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

any idea why logger does different characters for windows???

},
};

for (const [testName, {actual, expected, diff}] of Object.entries(testCases)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@exterkamp i basically wrote a go test

@connorjclark connorjclark merged commit f83b042 into master Jun 22, 2022
@connorjclark connorjclark deleted the report-assert-tests branch June 22, 2022 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants