Socket
Socket
Sign inDemoInstall

casper-chai

Package Overview
Dependencies
0
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.1

106

docs/casper-chai.md
<!--- AUTO-GENERATED BY CAKEFILE. Do not edit! -->
Casper-Chai Assertions
Language Chains
----------
#### element
The following are the assertion tests that are added onto Chai Assertion.
#### attr(attribute_name)
A language chain that sets an `element` flag that tells other casper-chai
assertions to not require all elements to match the criteria, but at least one.
True when the attribute `attribute_name` on `selector` is true.
```javascript
expect("ul.header li").to.have.an.element.with.attr('aria-selected')
```
If the selector matches more than one element with the attribute set, this
will fail. In those cases try [attrAll](#attrall) or [attrAny](#attrany).
In this example, the assertion with pass if any `li` has the `aria-selected` attribute.
Otherwise, by default `attr` will assert that all elements matched have that attribute.
#### evaluate
Change the assertion subject to the result of the expression evaluated
in the page. An expression may be a function, a function string, or a simple expression.
When a string is passed in it is wrapped in 'function () {}', with a 'return' statement
added if one is not already included, and this wrapped function is
evaluated as an ordinary function would be. When it is a function it is simply
evaluated in the page as is.
```javascript
expect("#my_header").to.have.attr('class')
"true".should.evaluate.to.true;
(function() { return false }).should.evaluate.to.false;
expect("function () { return true }").to.evaluate.to.true;
"document.querySelectorAll('body').length".should.evaluate.to.be.at.least(1);
var foo = function () { return typeof jQuery ; )
expect(foo).to.evaluate.to.be.undefined; // unless jQuery is installed.
"0 === -0".should.evaluate.to.be.false.wat
```
#### attrAny(attribute_name)
True when an attribute is set on at least one of the given selectors.
Casper-Chai Assertions
----------
The following are the assertion tests that are added onto `Chai.Assertion`.
#### attr(attributeName)
#### attribute(attributeName)
Asserts that attribute `attribute_name` are on all elements matched by `selector`.
If the `element` chain was used, it asserts that any element has that selector.
```javascript
expect("div.menu li").to.have.attrAny('selected')
expect("#my_header").to.have.attr('class')
expect("ul.header li").to.have.an.element.with.attribute('aria-selected')
```
#### attrAll(attribute_name)
True when an attribute is set on all of the given selectors.
It also changes the subject of the assertion to the attributes, so you can do
further assertions on those attributes
```javascript
expect("div.menu li").to.have.attrAll('class')
```
````javascript
"#tabs li a".should.have.an.element.with.attribute('aria-selected')[0].that.equals('true')
"section a.add".should.have.attr('data-bind')[0].and.contains('click:')
````
#### fieldValue

@@ -63,22 +94,2 @@

```
#### matchOnRemote
Compare the remote evaluation to the given expression, and return
true when they match. The expression can be a string or a regular
expression. The evaluation is the same as for
[`trueOnRemote`](#trueonremote).
```javascript
expect("return 123").to.matchOnRemote(123)
"typeof jQuery".should.not.matchOnRemote('undefined')
"123.toString()".should.matchOnRemote(/\d+/)
```
or an example in CoffeeScript
```coffeescript
(-> typeof jQuery).should.not.matchOnRemote('undefined')
```
#### matchTitle

@@ -130,27 +141,2 @@

```
#### trueOnRemote
The given expression evaluates to true on the remote page. Expression may
be a function, a function string, or a simple expression. Where a function
is passed in, the return value is tested. Where a simple expression is
passed in it is wrapped in 'function () {}', with a 'return' statement
added if one is not already included, and this wrapped function is
evaluated as an ordinary function would be.
```javascript
"true".should.be.trueOnRemote;
expect("true").to.be.trueOnRemote;
(function() { return false }).should.not.be.trueOnRemote;
expect("function () { return true }").to.be.trueOnRemote;
expect("return false").to.not.be.trueOnRemote;
var foo = function () { return typeof jQuery == typeof void 0; )
foo.should.be.trueOnRemote; // unless Query is installed.
expect("function () { return 1 == 0 }").to.not.be.trueOnRemote;
```
#### visible

@@ -157,0 +143,0 @@

@@ -10,3 +10,3 @@ {

],
"version": "0.2.0",
"version": "0.2.1",
"author": "Brian M Hunt <brianmhunt@gmail.com>",

@@ -13,0 +13,0 @@ "license": "MIT",

@@ -60,3 +60,3 @@ # Casper.JS Assertions for Chai [![Build Status](https://secure.travis-ci.org/brianmhunt/casper-chai.png?branch=master)](https://travis-ci.org/brianmhunt/casper-chai)

'body > header'.should.be.inDOM
(function() { document.querySelectorAll('li').count === 3 }).should.be.trueOnRemote
'document.querySelectorAll('li').count'.should.evaluate.to.be.above(2)
'#help-link'.should.have.attribute('href')[0].and.equal("/help")

@@ -63,0 +63,0 @@ 'ul.breadcrumbs li'.should.contain.an.element.with.attr('aria-selected')

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc