Questions tagged [zombiejs]

Fast, full-stack, headless browser testing using Node.js

Zombie.js is a lightweight framework for testing client-side JavaScript code in a simulated environment. No browser required.

const Browser = require('zombie');

// We're going to make requests to http://example.com/signup
// Which will be routed to our test server localhost:3000
Browser.localhost('example.com', 3000);

describe('User visits signup page', function() {

    const browser = new Browser();

    before(function(done) {
        browser.visit('/signup', done);
    });

    describe('submits form', function() {

        before(function(done) {
            browser
                .fill('email',    'zombie@underworld.dead')
                .fill('password', 'eat-the-living')
                .pressButton('Sign Me Up!', done);
        });

        it('should be successful', function() {
            browser.assert.success();
        });

        it('should see welcome page', function() {
            browser.assert.text('title', 'Welcome To Brains Depot');
        });
    });
});

This example uses the Mocha testing framework, but Zombie will work with other testing frameworks. Since Mocha supports promises, we can also write the test like this:

const Browser = require('zombie');

// We're going to make requests to http://example.com/signup
// Which will be routed to our test server localhost:3000
Browser.localhost('example.com', 3000);

describe('User visits signup page', function() {
    const browser = new Browser();

    before(function() {
        return browser.visit('/signup');
    });

    describe('submits form', function() {

        before(function() {
            browser
              .fill('email',    'zombie@underworld.dead')
              .fill('password', 'eat-the-living');
            return browser.pressButton('Sign Me Up!');
        });

        it('should be successful', function() {
            browser.assert.success();
        });

        it('should see welcome page', function() {
            browser.assert.text('title', 'Welcome To Brains Depot');
        });
    });
});

Project site with full documentation

6 questions
2
votes
1 answer

How to process a big array applying a async function for each element in nodejs?

I am working with zombie.js to scrape one site, I must to use the callback style to connect to each url. The point is that I have got an urls array and I need to process each urls using an async function. This is my first approach: Array urls =…
dlopezgonzalez
  • 4,217
  • 5
  • 31
  • 42
2
votes
0 answers

Can we do the assertion in the callback of `browser.visit` as the document shows?

In the document of http://zombie.js.org/, there is an example: browser.visit('/path', function() { assert(browser.location.href == 'http://example.com/path'); }); It does the assertion in the callback of browser.visit, is it the correct way? When…
Freewind
  • 193,756
  • 157
  • 432
  • 708
1
vote
0 answers

Fetch error 404 on post request (Javascript)

I am using the Fetch API built into ZombieJS at the moment and am currently trying to send a post request to a URL stored as a variable (in my code it is labeled as "link"). When I display the output of the post request, I see the status code is…
1
vote
0 answers

Accessing request body with ZombieJS

I'm using ZombieJS v4 (4.0.13), and am trying to access the client's request body, since some tests require me to monitor the fields that are automatically sent via client forms. While I can access all the query-string fields by using the pipeline's…
yassa
  • 68
  • 4
0
votes
1 answer

ZombieJs click event does not fire

I'm using ZombieJs for web scraping, what I'm trying to is that when it clicks an element it would display html element of a new page but right now it returns nothing. const Browser = require('zombie'); Browser.visit(("url"), function(error,…
Gregor
  • 29
  • 5
0
votes
0 answers

Zombiejs document function callback

I'm trying to call a method on an object in window which can have a callback, like this: it('should be logged in into Facebook', function(done){ browser.visit('/test').then(function(){ browser.window.FB.getLoginStatus(function(response) { …
Anton
  • 55
  • 1
  • 9