cypress-ag-grid icon indicating copy to clipboard operation
cypress-ag-grid copied to clipboard

Question: Smoother comparison of Actual and Expected?

Open carwei opened this issue 2 years ago • 4 comments

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.

carwei avatar Jun 16 '22 09:06 carwei

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!

kpmck avatar Jun 22 '22 02:06 kpmck

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?

carwei avatar Jun 22 '22 06:06 carwei

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

kpmck avatar Jun 22 '22 12:06 kpmck

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.

carwei avatar Jun 22 '22 13:06 carwei