How to loop through rows of data in .CSV file in Cypress test?

In my Cypress test, I am trying to read data from a CSV file & loop through each row.

Below is the contents of my fixtures/logins.csv file:

| username | password    |
| john     | pword1      |
| james    | myPassword  |
| frank    | newPassword |

I want to loop through each row of data to log into an application.

Here is my latest code, it just logs the CSV file data as a string currently:

const csvUploaded = 'cypress/fixtures/logins.csv'

it('CSV test', () => {
    cy.readFile(csvUploaded, 'utf-8').then((txt) => {
        cy.log(txt)
        cy.log(typeof txt)
    });
});

txt is the below string at the moment:

username,password john,pword1 james,myPassword frank,newPassword


Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations