Category: How do I do X?
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Is there a way to do automated testing of Appsmith apps?

Issue

As an Appsmith user, I am looking for ways to automate the testing of my apps. Currently, testing is done manually and I am seeking options to automate the process. Suggestions include experimenting with Cypress or trying out puppeteer for manual setup.

Resolution

To automate testing for apps built in Appsmith, there are two options available - Cypress and Puppeteer.

Cypress is a popular end-to-end testing framework that allows developers to write and run tests for web applications. It supports multiple browsers, provides a clean and simple API, and generates visual reports. Developers can write tests in JavaScript and use Cypress' API to interact with the UI elements of their app. Here's an example of a Cypress test:

describe('Appsmith app', () => {
it('should show welcome message', () => {
cy.visit('https://myapp.appsmith.com');
cy.contains('Welcome to Appsmith').should('be.visible');
});
});

Puppeteer, on the other hand, is a Node library that provides a high-level API to control headless Chrome or Chromium. It can be used to automate UI testing, web scraping, and other browser automation tasks. Developers can write scripts in JavaScript that simulate user inputs and interactions on their app. Here's an example Puppeteer script that navigates to a page and takes a screenshot:

const puppeteer = require('puppeteer');

(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://myapp.appsmith.com');
await page.screenshot({ path: 'myapp.png' });
await browser.close();
})();

Both Cypress and Puppeteer provide options for running tests locally or in the cloud, and can be integrated with CI/CD pipelines for continuous testing. By automating testing, developers can ensure that their app is working as intended with less manual effort and faster feedback on changes.