1

I'm writing some end-to-end automated tests for a CRM-alike web application. One of the development team leaders is asking me to do something that I've never done before.

The problem is that the data that is being displayed in the views of the application is sometimes different after each synchronization/deployment, but the data should always be the same.

The data comes from different stored procedures inside a SQL Server database, and they are using some kind of soft coding solution to develop the application and connect it to these stored procedures. I would like to know if it is possible and advisable to include this data verification in the automation process (as they are asking me to do) and what solutions would be appropriate for this.

We are using Cypress as our automation tool. The idea would be to somehow store the data after running the automated tests, and then the next time we run the tests again, the stored data is compared against the data of the current execution. If the data is different, that should cause the tests to fail.

This is my first time asking a question here, any ideas?

5 Answers 5

1

It is certainly possible to include data verification in your automated tests, and it can be a useful way to ensure that your application is functioning correctly.

One approach you could take is to create a reference set of data that you expect to see in the application views. This reference set could be stored in a file or a database, depending on your preference.

During the automated tests, you can retrieve the data from the application views and compare it to the reference set. If the data is different, you can cause the tests to fail.

In Cypress, you can use the expect function to compare the data and throw an error if it does not match the expected value. For example:

cy.get('#data-element').then((data) => {
  expect(data).to.equal(referenceData);
});

Alternatively, you could use a tool like Jest to create data snapshots and compare them to the reference data. This can be a more lightweight approach, but it does require you to manually update the snapshot data whenever the reference data changes.

It's worth noting that data verification can be a time-consuming process, especially if you have a large amount of data to compare. You may want to consider focusing on the most important data points first, and adding additional verification steps as needed.

0

This is called snapshot testing (because you're comparing the app data to a "snapshot" that represents the expected data), and you can do it manually by storing your data in a file (usually in the fixtures/ directory), loading it during the test, and asserting that it matches the data in the app. See the documentation for cy.fixture(), and Fixture examples.

There are plugins that help with that by providing Cypress commands. For example: @cypress/snapshot.

0

If you know the output data, you can uses fixture folder to create a json file(or any other file) to store data in a proper format. There after you can compare data in the file with the new data. If you give more details about the output data it will be more clear to provide a better answer.

If you can try intercepting to the API. If you do it, you can get response body to compare data directly without dealing with UI element. API will have a json and also have created a json using a previous data.

0

Yes, we can perform data validation by using Cypress.

Steps-

1.Integrate MySQL Plugin in Package.Json file.

2.Design SQL connectivity code in .js file with appropriate database connection String

3.Use Cypress cy.task() to execute SQL queries from cypress and then we can compare that data with any Webpage or BI Report data.

-1

Yes that's possible. You can use something like writing your data into Cypress/fixture and store it in a json/csv file. The next time you run the code, you

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 26, 2022 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.