🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

codeceptjs

Package Overview
Dependencies
Maintainers
1
Versions
262
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

1.0.1
Source
npm
Version published
Weekly downloads
202K
30.94%
Maintainers
1
Weekly downloads
 
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

tdd

FAQs

Package last updated on 10 Aug 2017

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