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

codeceptjs

Package Overview
Dependencies
Maintainers
1
Versions
235
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codeceptjs

Modern Era Acceptance Testing Framework for NodeJS

  • 2.3.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is codeceptjs?

CodeceptJS is an end-to-end testing framework for Node.js that simplifies the process of writing and running tests for web applications. It supports various testing engines like WebDriver, Puppeteer, TestCafe, and more, allowing for flexible and powerful test automation.

What are codeceptjs's main functionalities?

End-to-End Testing

CodeceptJS allows you to write end-to-end tests in a simple and readable format. This example demonstrates a basic login test where the user navigates to the login page, fills in the username and password, clicks the login button, and verifies that the welcome message is displayed.

const { I } = inject();

Feature('Login');

Scenario('test login', (I) => {
  I.amOnPage('/login');
  I.fillField('Username', 'user');
  I.fillField('Password', 'password');
  I.click('Login');
  I.see('Welcome, user');
});

Page Object Model

CodeceptJS supports the Page Object Model (POM) design pattern, which helps in organizing and maintaining test code. This example shows a LoginPage class that encapsulates the elements and actions related to the login page, making the test code more modular and reusable.

class LoginPage {
  constructor() {
    this.fields = {
      username: 'input[name="username"]',
      password: 'input[name="password"]'
    };
    this.buttons = {
      login: 'button[type="submit"]'
    };
  }

  login(username, password) {
    I.fillField(this.fields.username, username);
    I.fillField(this.fields.password, password);
    I.click(this.buttons.login);
  }
}

module.exports = new LoginPage();

Data-Driven Testing

CodeceptJS supports data-driven testing, allowing you to run the same test with different sets of data. This example demonstrates how to create a data table with multiple user credentials and run the login test for each set of credentials.

const { I } = inject();

Feature('Login');

const users = new DataTable(['username', 'password']);
users.add(['user1', 'password1']);
users.add(['user2', 'password2']);

Data(users).Scenario('test login with multiple users', (I, current) => {
  I.amOnPage('/login');
  I.fillField('Username', current.username);
  I.fillField('Password', current.password);
  I.click('Login');
  I.see('Welcome, ' + current.username);
});

Other packages similar to codeceptjs

Keywords

FAQs

Package last updated on 06 Sep 2019

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