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

Question: Smoother comparison of Actual and Expected? #19

Open
carwei opened this issue Jun 16, 2022 · 4 comments
Open

Question: Smoother comparison of Actual and Expected? #19

carwei opened this issue Jun 16, 2022 · 4 comments

Comments

@carwei
Copy link

carwei commented Jun 16, 2022

Really love this tool. One thought though, I find myself doing a lot of troubleshooting the difference between Actual and Expected when the contents of a table change (or verifying if it changed as we intended for some reason). Do you have control ofter this output in the browser console? If so, would it be possible to feed the two arrays of objects to a visual comparison tool, by a link or something in the console log? I'm using https://jsondiff.com but I'll be happy to know what others use.

@kpmck
Copy link
Owner

kpmck commented Jun 22, 2022

Thanks, @carwei! Right now it's using general Chai assertions to do actual vs expected comparison. I would be open to PRs that investigate a smarter, clearer way to investigate! I am unsure which version you are using at this moment, but newer versions will print out the actual vs expected values for the grid in our output, which should make validation a tad bit easier.

When I have a moment, I'd be happy to look into how to make this a little easier to debug!

@carwei
Copy link
Author

carwei commented Jun 22, 2022

Thanks, @carwei! Right now it's using general Chai assertions to do actual vs expected comparison. I would be open to PRs that investigate a smarter, clearer way to investigate! I am unsure which version you are using at this moment, but newer versions will print out the actual vs expected values for the grid in our output, which should make validation a tad bit easier.

When I have a moment, I'd be happy to look into how to make this a little easier to debug!

I'm running version 1.30 so I have a console log output of the actual and expected values. It's just that the diff hunting can get a little bit tedious copy & pasting them into an external diff analyzer manually several times. Of course, cypress-ag-grid already makes my job easier so this is just something that would remove the friction that comes with finding out the diffs at the cell/row level.

Example from the docs

cy.get("#myGrid")
.getAgGridData()
.then((actualTableData) => {
    cy.get(agGridSelector).agGridValidateRowsExactOrder(actualTableData, expectedTableData);
});

Are you using Chai then instead of agGridValidateRowsExactOrder, passing actualTableData and expectedTableData to a Chai assertion? If so, in which cases are you using agGridValidateRowsExactOrder?

@kpmck
Copy link
Owner

kpmck commented Jun 22, 2022

Under the hood, it’s Chai assertions being executed for each of the agGridValidateX commands: https://github.com/kpmck/cypress-ag-grid/blob/master/src/agGrid/agGridValidations.js

@carwei
Copy link
Author

carwei commented Jun 22, 2022

Ok, good to know. As a next step, I think I'll look for an npm package to compare the diffs for me and highlight them in the console.

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

No branches or pull requests

2 participants