Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

testcafe

Package Overview
Dependencies
Maintainers
7
Versions
464
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testcafe

Automated browser testing for the modern web development stack.

  • 3.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
188K
decreased by-3.68%
Maintainers
7
Weekly downloads
 
Created

What is testcafe?

TestCafe is an end-to-end testing framework for web applications. It allows you to write tests in JavaScript or TypeScript, run them across multiple browsers, and provides a rich set of features for automating user interactions and verifying application behavior.

What are testcafe's main functionalities?

Cross-browser Testing

TestCafe allows you to run tests across multiple browsers simultaneously. This code sample demonstrates how to set up TestCafe to run tests in both Chrome and Firefox.

const createTestCafe = require('testcafe');
let testcafe = null;

createTestCafe('localhost', 1337, 1338)
    .then(tc => {
        testcafe = tc;
        const runner = testcafe.createRunner();

        return runner
            .src('tests/test.js')
            .browsers(['chrome', 'firefox'])
            .run();
    })
    .then(failedCount => {
        console.log('Tests failed: ' + failedCount);
        testcafe.close();
    });

Assertions

TestCafe provides a rich set of assertions to verify the state of your application. This code sample demonstrates how to use assertions to check that the text of an element matches the expected value.

import { Selector } from 'testcafe';

fixture `Getting Started`
    .page `http://devexpress.github.io/testcafe/example`;

const developerNameInput = Selector('#developer-name');
const submitButton = Selector('#submit-button');
const articleHeader = Selector('#article-header');






test('My first test', async t => {
    await t
        .typeText(developerNameInput, 'John Smith')
        .click(submitButton)
        .expect(articleHeader.innerText).eql('Thank you, John Smith!');
});

Screenshots and Video Recording

TestCafe allows you to take screenshots and record videos of your tests. This code sample demonstrates how to take a screenshot after performing some actions.

import { Selector } from 'testcafe';

fixture `Screenshot and Video`
    .page `http://devexpress.github.io/testcafe/example`;

const developerNameInput = Selector('#developer-name');
const submitButton = Selector('#submit-button');






test('Take a screenshot', async t => {
    await t
        .typeText(developerNameInput, 'John Smith')
        .click(submitButton)
        .takeScreenshot();
});

Parallel Test Execution

TestCafe supports parallel test execution to speed up the testing process. This code sample demonstrates how to run tests in parallel with a concurrency factor of 3.

const createTestCafe = require('testcafe');
let testcafe = null;

createTestCafe('localhost', 1337, 1338)
    .then(tc => {
        testcafe = tc;
        const runner = testcafe.createRunner();

        return runner
            .src('tests/test.js')
            .browsers(['chrome', 'firefox'])
            .concurrency(3)
            .run();
    })
    .then(failedCount => {
        console.log('Tests failed: ' + failedCount);
        testcafe.close();
    });

Other packages similar to testcafe

Keywords

FAQs

Package last updated on 29 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc