Convert Figma logo to code with AI

DevExpress logotestcafe

A Node.js tool to automate end-to-end web testing.

9,807
667
9,807
36

Top Related Projects

46,847

Fast, easy and reliable testing for anything that runs in a browser.

88,205

JavaScript API for Chrome and Firefox

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

Next-gen browser and mobile automation test framework for Node.js

30,518

A browser automation framework and ecosystem.

Supercharged End 2 End Testing Framework for NodeJS

Quick Overview

TestCafe is an end-to-end testing framework for browser automation and UI testing. It allows developers to write and run tests for web applications across multiple browsers, including mobile devices, without the need for additional browser drivers or plugins.

Pros

  • Cross-Browser Testing: TestCafe supports a wide range of browsers, including desktop and mobile, making it easy to ensure your web application works consistently across different platforms.
  • Scriptless Testing: TestCafe provides a user-friendly API that allows you to write tests using JavaScript or TypeScript, without the need for complex scripting.
  • Parallel Test Execution: TestCafe can run tests in parallel, significantly reducing the time it takes to complete your test suite.
  • Robust Reporting: TestCafe offers detailed test reports, including screenshots and videos, making it easier to debug and identify issues.

Cons

  • Learning Curve: While the TestCafe API is relatively straightforward, there may be a learning curve for developers who are new to end-to-end testing.
  • Limited Integrations: TestCafe may not have as many integrations with other testing tools and frameworks as some of its competitors.
  • Performance Overhead: Running tests in multiple browsers can be resource-intensive, which may impact the performance of your development environment.
  • Dependency on Browser Compatibility: TestCafe's functionality is dependent on the compatibility of the browsers it supports, which can be a concern as browsers are constantly evolving.

Code Examples

import { Selector } from 'testcafe';

fixture `Google Search`
    .page `https://www.google.com`;

test('Search for "TestCafe"', async t => {
    await t
        .typeText('#q', 'TestCafe')
        .pressKey('enter')
        .expect(Selector('title').innerText).contains('TestCafe');
});

This example demonstrates how to write a simple test case using TestCafe. The test navigates to the Google homepage, types "TestCafe" into the search box, and then verifies that the page title contains "TestCafe".

import { Selector, ClientFunction } from 'testcafe';

fixture `GitHub Repository`
    .page `https://github.com/DevExpress/testcafe`;

test('Verify repository information', async t => {
    const getPageUrl = ClientFunction(() => window.location.href);
    const repoName = await Selector('h1.h2.lh-condensed').innerText;
    const repoDescription = await Selector('.color-fg-muted').innerText;

    await t
        .expect(getPageUrl()).contains('DevExpress/testcafe')
        .expect(repoName).eql('DevExpress/testcafe')
        .expect(repoDescription).contains('Browser Automation Framework');
});

This example demonstrates how to use TestCafe's Selector and ClientFunction APIs to interact with and verify the content of a GitHub repository page.

import { Selector, t } from 'testcafe';

fixture `Login Test`
    .page `https://example.com/login`;

test('Login with valid credentials', async () => {
    await t
        .typeText('#username', 'testuser')
        .typeText('#password', 'testpassword')
        .click('#login-button')
        .expect(Selector('#welcome-message').exists).ok();
});

This example shows how to write a test case in TypeScript to verify the login functionality of a web application.

Getting Started

To get started with TestCafe, follow these steps:

  1. Install TestCafe using npm:
npm install -g testcafe
  1. Create a new file (e.g., test.js) and write your first test:
import { Selector } from 'testcafe';

fixture `Google Search`
    .page `https://www.google.com`;

test('Search for "TestCafe"', async t => {
    await t
        .typeText('#q', 'TestCafe')
        .pressKey('enter')
        .expect(Selector('title').innerText).contains('TestCafe');
});
  1. Run the test using the testcafe comman

Competitor Comparisons

46,847

Fast, easy and reliable testing for anything that runs in a browser.

Pros of Cypress

  • Built-in automatic waiting and retry mechanisms, reducing flaky tests
  • Rich, interactive test runner with time-travel debugging
  • Extensive documentation and active community support

Cons of Cypress

  • Limited cross-browser support (primarily focused on Chrome-based browsers)
  • Asynchronous nature can be challenging for developers new to JavaScript
  • Cannot interact with multiple browser tabs or windows in a single test

Code Comparison

TestCafe example:

test('Login Test', async t => {
  await t
    .typeText('#username', 'testuser')
    .typeText('#password', 'password123')
    .click('#login-button')
    .expect(Selector('.welcome-message').exists).ok();
});

Cypress example:

describe('Login Test', () => {
  it('should log in successfully', () => {
    cy.visit('/login')
    cy.get('#username').type('testuser')
    cy.get('#password').type('password123')
    cy.get('#login-button').click()
    cy.get('.welcome-message').should('exist')
  })
})

Both frameworks offer intuitive syntax for writing tests, but Cypress uses a chainable API structure, while TestCafe uses async/await. Cypress automatically handles waiting for elements, while TestCafe requires explicit await statements.

88,205

JavaScript API for Chrome and Firefox

Pros of Puppeteer

  • Direct control over Chrome/Chromium, allowing for more advanced browser automation
  • Faster execution due to direct browser control and no additional abstraction layers
  • Broader use cases beyond testing, including web scraping and performance analysis

Cons of Puppeteer

  • Steeper learning curve, especially for those unfamiliar with browser internals
  • Limited to Chromium-based browsers, lacking cross-browser testing capabilities
  • Requires more setup and configuration for test automation compared to TestCafe

Code Comparison

TestCafe example:

test('My Test', async t => {
  await t
    .typeText('#username', 'myUser')
    .typeText('#password', 'myPassword')
    .click('#login-button');
});

Puppeteer example:

await page.type('#username', 'myUser');
await page.type('#password', 'myPassword');
await page.click('#login-button');

Both TestCafe and Puppeteer are powerful tools for web automation and testing. TestCafe offers a more user-friendly approach with built-in test structure and assertions, making it easier for beginners to get started. Puppeteer, on the other hand, provides lower-level control over the browser, making it more versatile for advanced use cases but requiring more setup for test automation.

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

Pros of Playwright

  • Cross-browser support for Chromium, Firefox, and WebKit, offering broader coverage
  • Built-in auto-waiting mechanism, reducing the need for explicit waits
  • Powerful API for handling modern web features like shadow DOM and iframes

Cons of Playwright

  • Steeper learning curve due to more advanced features and concepts
  • Larger package size and potentially higher resource usage
  • Relatively newer project with a less mature ecosystem compared to TestCafe

Code Comparison

TestCafe example:

test('Login Test', async t => {
  await t
    .typeText('#username', 'testuser')
    .typeText('#password', 'password123')
    .click('#login-button')
    .expect(Selector('.welcome-message').exists).ok();
});

Playwright example:

test('Login Test', async ({ page }) => {
  await page.fill('#username', 'testuser');
  await page.fill('#password', 'password123');
  await page.click('#login-button');
  await expect(page.locator('.welcome-message')).toBeVisible();
});

Both frameworks offer concise and readable syntax for writing tests. Playwright's API is more granular, allowing for finer control over actions and assertions. TestCafe's API is slightly more compact and may be easier for beginners to grasp quickly.

Next-gen browser and mobile automation test framework for Node.js

Pros of WebdriverIO

  • More flexible and extensible, supporting various automation protocols
  • Larger community and ecosystem with extensive third-party plugins
  • Better suited for complex, multi-platform testing scenarios

Cons of WebdriverIO

  • Steeper learning curve, especially for beginners
  • Requires more setup and configuration compared to TestCafe
  • Can be slower in execution due to its reliance on WebDriver protocol

Code Comparison

TestCafe example:

test('My Test', async t => {
  await t
    .typeText('#username', 'myUser')
    .typeText('#password', 'myPassword')
    .click('#login');
});

WebdriverIO example:

describe('My Test', () => {
  it('should login', async () => {
    await $('#username').setValue('myUser');
    await $('#password').setValue('myPassword');
    await $('#login').click();
  });
});

Both frameworks offer concise and readable test scripts, but WebdriverIO's syntax is more aligned with traditional JavaScript testing frameworks. TestCafe's API is designed to be more user-friendly and requires less boilerplate code. WebdriverIO provides more granular control over element interactions, while TestCafe abstracts some of these details for simplicity.

30,518

A browser automation framework and ecosystem.

Pros of Selenium

  • Wider language support (Java, Python, C#, Ruby, JavaScript)
  • Larger community and ecosystem with extensive resources
  • Native support for mobile testing (iOS and Android)

Cons of Selenium

  • More complex setup and configuration
  • Slower test execution compared to TestCafe
  • Requires separate WebDriver installations for different browsers

Code Comparison

Selenium (Python):

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://example.com")
element = driver.find_element(By.ID, "myElement")
element.click()
driver.quit()

TestCafe (JavaScript):

import { Selector } from 'testcafe';

fixture('My Fixture').page('https://example.com');

test('My Test', async t => {
    await t.click(Selector('#myElement'));
});

TestCafe offers a more straightforward syntax and doesn't require separate WebDriver setup. Selenium provides more flexibility in terms of language choice but requires more boilerplate code and explicit browser management.

Both tools are powerful for web testing, with Selenium offering broader language and platform support, while TestCafe provides a simpler setup and faster execution. The choice between them depends on specific project requirements and team preferences.

Supercharged End 2 End Testing Framework for NodeJS

Pros of CodeceptJS

  • More flexible and supports multiple testing backends (Puppeteer, Selenium WebDriver, Playwright)
  • Easier to write and read tests with a high-level, behavior-driven syntax
  • Strong community support and active development

Cons of CodeceptJS

  • Steeper learning curve due to its flexibility and multiple backend options
  • May require more setup and configuration compared to TestCafe's out-of-the-box experience
  • Performance can vary depending on the chosen backend

Code Comparison

TestCafe example:

test('Login test', async t => {
  await t
    .typeText('#username', 'myuser')
    .typeText('#password', 'mypassword')
    .click('#login-button')
    .expect(Selector('.welcome-message').exists).ok();
});

CodeceptJS example:

Feature('Login');

Scenario('Login test', ({ I }) => {
  I.amOnPage('/login');
  I.fillField('username', 'myuser');
  I.fillField('password', 'mypassword');
  I.click('Login');
  I.see('Welcome');
});

Both frameworks offer powerful testing capabilities, but CodeceptJS provides more flexibility and a higher-level syntax, while TestCafe offers a simpler setup and potentially better performance for web-specific testing.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Try TestCafe Studio IDE

testcafe

Tests Test Dependencies NPM Version

Automate end-to-end web testing with TestCafe, a Node.js-based testing framework.

TestCafe is free and as easy to use as 1-2-3:
1. Write your tests in JS or TypeScript.
2. Execute your tests.
3. View test results.

Homepage   â€¢   Documentation   â€¢   FAQ   â€¢   Support

  • Works on all popular environments: TestCafe runs on Windows, MacOS, and Linux. It supports desktop, mobile, remote and cloud browsers (UI or headless).
  • 1 minute to set up: You do not need WebDriver or any other testing software. Install TestCafe with one command, and you are ready to test: npm install -g testcafe
  • Free and open source: TestCafe is free to use under the MIT license. Plugins provide custom reports, integration with other tools, launching tests from IDE, etc. You can use the plugins made by the GitHub community or create your own.

Install TestCafe and Run a Test

Running a sample test in Safari

Table of contents

Features

Stable tests and no manual timeouts
TestCafe automatically waits for page loads and XHRs before the test starts and after each action. It also features smart test actions and assertions that wait for page elements to appear. You can change the maximum wait time. If elements load faster, tests skip the timeout and continue.

Rapid test development tool
When you enable live mode, changes to test code immediately restart the test, and you instantly see the results.

Latest JS and TypeScript support
TestCafe supports the most recent JavaScript-related features, including ES2017 (async/await). You can also use TypeScript if you prefer a strongly typed language instead.

Detects JS errors in your code
TestCafe reports JS errors that it locates on a given webpage. Tests automatically fail if TestCafe encounters such errors.
You can, however, disable this option.

Concurrent test launch
TestCafe can open multiple instances of the same browser and run parallel tests (to help decrease test execution time).

PageObject pattern support
The TestCafe's Test API includes a high-level selector library, assertions, etc. You can combine them to implement readable tests with the PageObject pattern.

const macOSInput = Selector('.column').find('label').withText('MacOS').child('input');

Easy to include in a continuous integration system
You can run TestCafe from a console, and its reports can be viewed within CI systems (TeamCity, Jenkins, Travis & etc.)

Love TestCafe Open-source Edition? Want to Record Tests without Writing JavaScript or TypeScript Code?

TestCafe Studio: IDE for End-to-End Web Testing

TestCafe is the perfect choice for JavaScript developers and experienced Q&A teams. If you’d like to delegate testing to QA engineers and are looking for a code-free way to record and maintain tests compatible with your existing infrastructure, check out TestCafe Studio - a testing IDE built atop the open-source version of TestCafe.

Review the following article to learn how TestCafe Studio can fit into any workflow: What's Better than TestCafe? TestCafe Studio.

Get Started with TestCafe Studio

Record and Run a Test in TestCafe Studio

Getting Started

Installation

Ensure that you run Node.js version 16 or higher, and run the following command:

npm install -g testcafe

Creating the Test

For this simple example, we will test the following page: https://devexpress.github.io/testcafe/example

Create a .js or .ts file on your computer. Remember that a .js or .ts file must maintain a specific structure: tests must be organized into fixtures. You can paste the following code to see the test in action:

import { Selector } from 'testcafe'; // first import testcafe selectors

fixture `Getting Started`// declare the fixture
    .page `https://devexpress.github.io/testcafe/example`;  // specify the start page


//then create a test and place your code within it
test('My first test', async t => {
    await t
        .typeText('#developer-name', 'John Smith')
        .click('#submit-button')

        // Use the assertion to check if actual header text equals expected text
        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');
});

Running the Test

Call the following command in a command shell. Specify the target browser and file path.

testcafe chrome test1.js

TestCafe opens the browser and begins test execution.

Important: Make certain the browser tab that runs tests stays active. Do not minimize the browser window. Inactive tabs and minimized browser windows switch to lower resource consumption mode. In low consumption mode, tests may not execute correctly.

Viewing the Results

TestCafe outputs results into a command shell by default. See Reporters for more information. You can also use plugins to customize reports.

Test Report

Read the Getting Started page for additional assistance.

Documentation

Visit the following webpage to review our online help system: Documentation.

Get Help

Join the TestCafe community on Stack Overflow. Ask and answer questions using the TestCafe tag.

Issue Tracker

Use our GitHub issues page to report bugs and suggest enhancements.

Stay in Touch

Follow us on Twitter. We post TestCafe news and updates.

Contributing

Read our Contributing Guide to learn how to contribute to the project.

To create your own plugin for TestCafe, you can use these plugin generators:

If you want your plugin to be listed below, send us a note in a Github issue.

Thanks to all of our contributors – We appreciate your commitment to the TestCafe community.

aha-oretamaaialeks-proAleksey28AlexanderMoiseevAlexanderMoskovkin
aha-oretamaaialeks-proAleksey28AlexanderMoiseevAlexanderMoskovkin
alexey-linAlexKamaevalexphilinAlexSkorkinalexwybraniecAnastasiaIvanova8
alexey-linAlexKamaevalexphilinAlexSkorkinalexwybraniecAnastasiaIvanova8
andrewbranchAndreyBelymAndyWendtAnnaKondratovaanthophobiacArtem-Babich
andrewbranchAndreyBelymAndyWendtAnnaKondratovaanthophobiacArtem-Babich
Arthy000augustomezencio-hotmartbdwainbenmonrobeyondcomputebill-looby-i
Arthy000augustomezencio-hotmartbdwainbenmonrobeyondcomputebill-looby-i
bsmithb2caseyWebbcdrinicgfarmer4Chris-Greaveschurkin
bsmithb2caseyWebbcdrinicgfarmer4Chris-Greaveschurkin
dej611DIRECTcutDmitry-OstasheveignatyevericydFarfurix
dej611DIRECTcutDmitry-OstasheveignatyevericydFarfurix
flora8984461GeoffreyBoothhelen-dikarevahonsq90infctrinikulin
flora8984461GeoffreyBoothhelen-dikarevahonsq90infctrinikulin
Ivan-Katovichjamesgeorge007jaypeajosephmalamkanhaiya15karolnowinski
Ivan-Katovichjamesgeorge007jaypeajosephmalamkanhaiya15karolnowinski
kirovboriskisrefodLavrovArtemlink89lzxbmacdonaldr93
kirovboriskisrefodLavrovArtemlink89lzxbmacdonaldr93
MargaritaLosevaMarketionistMatthewNielsen27mattkubejmattmanskemcjim
MargaritaLosevaMarketionistMatthewNielsen27mattkubejmattmanskemcjim
miherlosevmorfey13mostlyfabulousmurajun1978NickCisNuarat
miherlosevmorfey13mostlyfabulousmurajun1978NickCisNuarat
OgurecherPayBaspgornypietrovichradarhereraspo
OgurecherPayBaspgornypietrovichradarhereraspo
rbardinirenancoutorob4629rueyaa332266sgrillon14smockle
rbardinirenancoutorob4629rueyaa332266sgrillon14smockle
stefanschenksuperromasylbrutaiki-fwtestcafe-build-bottheghostbel
stefanschenksuperromasylbrutaiki-fwtestcafe-build-bottheghostbel
titermantobiasbueschelvarunkumarVasilyStrelyaevvitalicsVla8islav
titermantobiasbueschelvarunkumarVasilyStrelyaevvitalicsVla8islav
wentwrongb12031106danielroedanieltrogerDevSideintermike
wentwrongb12031106danielroedanieltrogerDevSideintermike
kirillsalikhovmichaelficarrarr13ktomashanacekTrevorKarjanis
kirillsalikhovmichaelficarrarr13ktomashanacekTrevorKarjanis

Plugins

TestCafe developers and community members made these plugins:

Different Versions of TestCafe

 TestCafeTestCafe Studio
No need for WebDriver, browser plugins or other tools
Cross-platform and cross-browser out of the box
Write tests in the latest JavaScript or TypeScript
Clear and flexible API supports ES6 and PageModel pattern
Stable tests due to the Smart Assertion Query Mechanism
Tests run fast due to intelligent Automatic Waiting Mechanism and Concurrent Test Execution
Custom reporter plugins
Use third-party Node.js modules in test scripts
Integration with popular CI systems ✓*
Free and open-source 
Visual Test Recorder 
Interactive Test Editor 
Automatic Selector Generation 
Run Configuration Manager 
IDE-like GUI 

* You can use open-source TestCafe to run TestCafe Studio tests in CI systems.

Badge

Show everyone you are using TestCafe: Tested with TestCafe

To display this badge, add the following code to your repository readme:

<a href="https://github.com/DevExpress/testcafe">
    <img alt="Tested with TestCafe" src="https://img.shields.io/badge/tested%20with-TestCafe-2fa4cf.svg">
</a>

Thanks to BrowserStack

We are grateful to BrowserStack for providing the infrastructure that we use to test code in this repository.

BrowserStack Logo

License

Code released under the MIT license.

Creators

Developer Express Inc. (https://devexpress.com)

NPM DownloadsLast 30 Days