Does anyone know whether there is anything similar to capybara for Node.js?
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");
});