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

nightwatch

Package Overview
Dependencies
Maintainers
2
Versions
355
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nightwatch

Easy to use Node.js based end-to-end testing solution for web applications using the W3C WebDriver API.

  • 2.4.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
151K
decreased by-10.06%
Maintainers
2
Weekly downloads
 
Created

What is nightwatch?

Nightwatch is an end-to-end testing framework for web applications and websites, written in Node.js. It uses the W3C WebDriver API to perform commands and assertions on DOM elements. Nightwatch is designed to be easy to set up and use, and it provides a powerful and flexible API for writing tests.

What are nightwatch's main functionalities?

End-to-End Testing

Nightwatch allows you to perform end-to-end testing by automating browser interactions. This example initializes the browser, navigates to a URL, waits for the body element to be visible, asserts the page title, and then ends the session.

const { client } = require('nightwatch');

client.init()
  .url('http://example.com')
  .waitForElementVisible('body', 1000)
  .assert.title('Example Domain')
  .end();

Page Object Model

Nightwatch supports the Page Object Model, which helps in organizing your test code by separating the page-specific selectors and actions from the test logic. This example shows how to define a page object and use it in a test.

module.exports = {
  url: 'http://example.com',
  elements: {
    body: 'body',
    title: 'title'
  }
};

// In your test file
const examplePage = client.page.example();

examplePage.navigate()
  .waitForElementVisible('@body', 1000)
  .assert.title('Example Domain');

Assertions

Nightwatch provides a variety of built-in assertions to validate the state of your application. This example demonstrates how to assert that the body element contains specific text.

client.init()
  .url('http://example.com')
  .waitForElementVisible('body', 1000)
  .assert.containsText('body', 'Example Domain')
  .end();

Other packages similar to nightwatch

Keywords

FAQs

Package last updated on 03 Nov 2022

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