![New axobject-query Maintainer Faces Backlash Over Controversial Decision to Support Legacy Node.js Versions](https://cdn.sanity.io/images/cgdhsj6q/production/86e6ebdea652d20da070ebbda20134b839972db7-1024x1024.webp?w=800&fit=max&auto=format)
Security News
New axobject-query Maintainer Faces Backlash Over Controversial Decision to Support Legacy Node.js Versions
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.
casper-chai
Advanced tools
Readme
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 assertions. Instead of using Casper's Tester you can use (in this case with mocha-casperjs 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
});
});
});
Say we have a page like this:
<html>
<head>
<title>Casper-Chai Example</title>
<link rel="stylesheet" href="site.css" type="text/css">
</head>
<body>
<header>
<a href="javascript:void(0)" class="signin">Sign In</a>
</header>
<article>
<ul class="breadcrumbs">
<li>Home</li>
<li>Blog</li>
<li aria-selected="true">Using Chai in your casper tests</li>
</ul>
<div class="greeting">Hello</div>
<span class="greeting help">Need help?</span>
</article>
<footer>
<a href="/help" id="help-link" class="help">Help</a>
</footer>
</body>
</html>
Here are some assertions that pass
expect(/Casper/).to.matchTitle
'Casper-Chai Example'.should.matchTitle
'site.css'.should.be.loaded
'body > header'.should.be.inDOM
(function() { document.querySelectorAll('li').count === 3 }).should.be.trueOnRemote
'#help-link'.should.have.attribute('href')[0].and.equal("/help")
'ul.breadcrumbs li'.should.contain.an.element.with.attr('aria-selected')
'.greeting'.should.have.tagName(['div', 'span'])
'li[aria-selected]'.should.contain.text('Using Chai')
'header a'.should.have.text(/Sign/)
'.greeting'.should.not.have.text(/Bye/)
Here are some assertions that fail
'li'.should.have.attr('aria-selected')
'li'.should.not.have.an.element.with.attr('aria-selected')
'.greeting'.should.not.have.tagName('span')
'.help'.should.have.text('Help')
'li[aria-selected]'.should.have.text('Using Chai')
See the full documentation and more examples, and if you are cool with CoffeeScript, check out the unit tests.
Casper-Chai can be installed with npm using npm install casper-chai
, or
including
casper-chai.coffee
in a directory require
will find it.
Add extensions to Chai with:
casper_chai = require('casper-chai');
chai.use(casper_chai);
To develop and test casper-chai locally, clone the project and run npm install
to get dependencies
(which, obviously, requires npm to be installed). You will need cake
to generate documentation - which should be possible by running npm install -g coffee-script
. Also make sure you have the latest version of casperjs installed.
FAQs
Extends Chai with assertions for CasperJS testing.
The npm package casper-chai receives a total of 127 weekly downloads. As such, casper-chai popularity was classified as not popular.
We found that casper-chai demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.
Security News
Results from the 2023 State of JavaScript Survey highlight key trends, including Vite's dominance, rising TypeScript adoption, and the enduring popularity of React. Discover more insights on developer preferences and technology usage.
Security News
The US Justice Department has penalized two consulting firms $11.3 million for failing to meet cybersecurity requirements on federally funded projects, emphasizing strict enforcement to protect sensitive government data.