Does anyone know whether there is anything similar to capybara for Node.js?
We created a complete acceptance testing solution in JS
http://xolv.io/products/chimp
It uses CucumberJS (Mocha/Jasmine soon) to drive your acceptance tests
- Downloads and starts Phantom / Selenium
- Injects a preconfigured Webdriver.IO instance into the testing context
- Includes the
request
npm library (for REST) the assertion library of your choice (Chai / Jasmine-expect)- Uses fibers for synchronous testing (no callback hell / promise confusion)
- Works with SauceLabs / BrowserStacks etc
- Support outside in testing with a watch mode that continuously runs the scenarios you tag with
@focus
- Supports CI out of the box and tested on Circle/Codeship/Travis (using headless Chrome/Firefox)
It doesn't make you coffee, yet
In terms of acceptance testing, I have heavily used Capybara for Rails. And I am unhappy with the alternatives listed here for NodeJS. You will want a popular web automation utility combined with the ability to make assertions against scenarios of a particular feature.
When you think of web automation in Node, Phantom and, thus, Casper is dead. So what is in the rise as of now? Puppeteer. I started using Puppeteer a few years ago when it was in beta and few articles and SO posts about it. But now Puppeteer is becoming the leader of web automation in Node. However, you cannot assert things in Puppeteer which is what you would expect from a testing framework.
But that doesn't stop us from integrating a testing tool into Puppeteer web automation. I found a few solutions using jest as the testing tool.
const puppeteer = require('puppeteer');
describe('Open Website', () => {
var browser, page;
var url = 'https://website.io'
beforeEach (async () => {
browser = await puppeteer.launch({ headless: false });
page = await browser.newPage();
})
afterEach (() => {
browser.close()
})
test('Title == Website Tools', async () => {
await page.goto(url);
const title = await page.title();
expect(title).toBe("Website Tools");
});
How about Zombie?
Zombie.js
Insanely fast, headless full-stack testing using Node.js
The Bite
If you're going to write an insanely fast, headless browser, how can you not call it Zombie Zombie it is.
Zombie.js is a lightweight framework for testing client-side JavaScript code in a simulated environment. No browser required.
Hy!
I've created a library to help out with cucumber-js. It gives you callable steps and parsed arguments. This works with cucumber and doesn't replace it.
Quick features:
https://github.com/hackhat/cucumberry
Hope you find it useful (:
Cucumber-JS is the closest you will get in Javascript: https://github.com/cucumber/cucumber-js
You can use the library to drive JS, headless and Selenium, however it is missing the 'capybara' shared API between each of the different 'worlds'. There is a good talk at http://skillsmatter.com/podcast/agile-testing/cucumber-js-cuke-up-your-javascript and supporting github code at https://github.com/jbpros/cukecipes
I'm hoping that when the phantomjs webdriver wire protocol is finished (https://github.com/detro/ghostdriver) and if Soda/Selenium (https://github.com/LearnBoost/soda) is able to drive it then the headless tests will be able to be automated via Selenium thus bypassing the need for Capybara.
See jelly.io:
Jellyfish is a Node project that aims to make it easy to launch different JavaScript environments and run your code.