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

casper-chai

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

casper-chai

Extends Chai with assertions for CasperJS testing.

  • 0.1.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
122
increased by3.39%
Maintainers
1
Weekly downloads
 
Created
Source

Casper.JS Assertions for Chai Build Status

Casper–Chai provides a set of custom assertions for use with CasperJS. You get all the benefits of Chai to test with CasperJS.

It is an alternative to Casper's built-in Tester. Instead of using Casper's Tester you can use (in this case with Mocha and Chai):

describe("my page", function () {
  it("can be opened by Casper", function () {
    casper.open("http://www.google.com")

    casper.then(function () {
      expect(casper.currentHTTPStatus).to.equal(200);
    });

    casper.then(function () {
      expect("Google").to.matchTitle
    });
  });
});

Tests

NameDescription
fieldValue(value) the named input provided has the given value
inDOMwhen the given selector is in the DOM
loadedwhen the given resource exists
matchCurrentUrlthe current URL matches
matchOnRemotecompare the remote evaluation to the given expression
matchTitlethe current Title matches
textInDOMthe text can be found in the DOM
textMatch(expression) the text of the given selector matches the expression (a string or regular expression).
trueOnRemotethe remote expression evaluates to something truthy
visiblethe selector matches a visible element

More documentation and examples.

For even more examples, if you are cool with CoffeeScript, check out the unit tests.

Installation

Casper-Chai can be installed with npm using npm install casper-chai, or including build/casper-chai.js in a directory require will find it.

Add extensions to Chai with:

casper_chai = require('casper-chai');
chai.use(casper_chai);

To build locally, clone the project and run cake toast test in the project directory. You may have to run npm install to get dependencies (which, obviously, requires npm to be installed), and make sure cake is available - which should be possible by running npm install -g coffee-script.

AMD

Casper–Chai supports being used as an AMD module, registering itself anonymously (just like Chai).

Keywords

FAQs

Package last updated on 10 Dec 2012

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