Writing Cypress Tests for ToolJet Applications
This guide walks through writing Cypress tests for a ToolJet application using the data-cy selectors that ToolJet generates automatically for every named component.
Prerequisites​
- A deployed ToolJet application with components named in the builder
- Node.js installed in your project
Install Cypress if you haven't already:
npm install cypress --save-dev
Finding Your Selectors​
Open DevTools on your deployed application and search for data-cy. Every named component is already tagged and ready to use.
Your First Test​
cy.visit("https://app.tooljet.com/applications/your-app");
cy.get('[data-cy="btnfetchusers-button"]').click();
cy.get('[data-cy="tableusers-name-row-0"]').should("contain.text", "Leanne Graham");
Visit the application, click a button, verify the result. No page objects, no selector hunting, no DOM traversal.
Testing a Complete User Workflow​
The following example tests a full search-and-detail workflow:
// Type a username to filter
cy.get('[data-cy="inputusername-input"]').clear().type("Bret");
// Fetch results
cy.get('[data-cy="btnfetchusers-button"]').click();
// Verify the correct user appears in the table
cy.get('[data-cy="tableusers-name-row-0"]').should("contain.text", "Leanne Graham");
cy.get('[data-cy="tableusers-username-row-0"]').should("contain.text", "Bret");
// Click the row to open the detail panel
cy.get('[data-cy="tableusers-row-0"]').click();
// Verify detail panel content
cy.get('[data-cy="text3-text"]').should("contain.text", "Leanne Graham");
cy.get('[data-cy="text5-text"]').should("contain.text", "[email protected]");