cypress-csv2html-plugin
Version:
A simple plugin to generate HTML table from CSV file by using cy.csv2html('/fixtures/yourfile.csv'), all the data is randomly generated
53 lines (39 loc) • 1.21 kB
Markdown
<h2 align=center> cypress-csv2html-plugin </h2>
<p align="center">
A simple plugin to wrap a CSV file into HTML, this plugin also generates a **data-test**
```
npm i -D cypress-csv2html-plugin
yarn add -D cypress-csv2html-plugin
pnpm add cypress-csv2html-plugin
bun add -D cypress-csv2html-plugin
```
Import into e2e.js
```js
import { csv2html } from "cypress-csv2html-plugin";
csv2html();
```
Then use the custom command `cy.csv2html`
```js
cy.csv2html('cypress/fixtures/example.csv')
```
You can use **data-test** for your tests
```
cy.get('[data-test="csv-table-container"]') // Check the table values
cy.get('[data-test="csv-table-header"]').contains('First Name') // Check the header values
cy.get('[data-test="csv-table-cell"]').contains('Linda') // Check the cell value
```
To get IntelliSense working with the default custom command `cy.csv2html` include in your specs
```js
/// <reference types="cypress-csv2html-plugin" />
```
Author: Nikita Polyakov
License: MIT
Support: if you find any problems with this module, email / tweet /
[ ](https://github.com/nikepol/cypress-csv2html-plugin/issues) on Github