Questions tagged [zombie.js]

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

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

221 questions
75
votes
10 answers

AngularJS - server-side rendering

As you may know, AirBnb opensourced Rendr (http://nerds.airbnb.com/weve-open-sourced-rendr) which should enable server-side rendering of Backbone apps. This is cool, because one can run the first "iteration" of template rendering on the server and…
tillda
  • 18,150
  • 16
  • 51
  • 70
35
votes
3 answers

Scrape a webpage and navigate by clicking buttons

I want to perform following actions at the server side: 1) Scrape a webpage 2) Simulate a click on that page and then navigate to the new page. 3) Scrape the new page 4) Simulate some button clicks on the new page 5) Sending the data back to the…
user2129794
  • 2,388
  • 8
  • 33
  • 51
28
votes
2 answers

Mock/Test Mongodb Database Node.js

I am learning nodejs and I have a mongodb database with which i have to interact with. I am currently thinking of using mocha for a unit test framework and zombie.js for a acceptance test framework. I was wondering how could I do full scale…
GTDev
  • 5,488
  • 9
  • 49
  • 84
20
votes
3 answers

Mocha and ZombieJS

I'm starting a nodejs project and would like to do BDD with Mocha and Zombiejs. Unfortunately I'm new to just about every buzzword in that sentence. I can get Mocha and Zombiejs running tests fine, but I can't seem to integrate the two - is it…
Joel
  • 2,217
  • 5
  • 34
  • 45
20
votes
1 answer

Performance of phantom.js vs zombie.js

I'm evaluating phantom.js and zombie.js. I expected the trade-off to be that phantom has wider documents support (since it uses a real renderer) while zombie is faster (since no rendering engine is used). However zombie seems much slower in the test…
Yaron Naveh
  • 23,560
  • 32
  • 103
  • 158
18
votes
2 answers

Setup/teardown of express.js application with mocha

I'm trying to create a standalone test suite using mocha, that in a perfect world would start up my express.js application, use zombie to render a page, check a bunch of stuff and then teardown/kill the express.js application. Is there an easy/best…
mrmagooey
  • 4,832
  • 7
  • 37
  • 49
16
votes
1 answer

How to use browser.wait() in zombie.js?

I've got a Web application that continuously polls for data from the server using Ajax requests. I would like to implement an integration test for it using zombie.js. What I am trying to do is to wait until the Ajax poll loop receives data from the…
fstab
  • 992
  • 1
  • 11
  • 19
13
votes
2 answers

what browser does zombie.js use?

So I came across zombie.js, is this a headless browser? If so, what browser engine does it use? Could I rely on it for doing lot of automated tests? Basically, I am restricted to a single server, so I would like to squeeze as many browser tests as…
KJW
  • 15,035
  • 47
  • 137
  • 243
12
votes
3 answers

How to install Zombie JS on Windows 7? (node.js headless browser)

I am having issues, could you point me in the right direction? EDIT: This module (Contextify) will not install from npm on Windows. See https://github.com/brianmcd/contextify/issues/10 for more info. This is because npm doesn't support C++ modules…
Mars Robertson
  • 12,673
  • 11
  • 68
  • 89
11
votes
1 answer

Why does the zombie.js browser return empty HTML when using Bootstrap?

I'm trying to test my Node.js/Express.js application using Mocha and Zombie. I can get simple tests to pass, but as soon as I add the script tags for Twitter Bootstrap to my views, the browser object returns empty HTML. Here is my test…
Andrew Patzer
  • 255
  • 1
  • 4
  • 9
10
votes
1 answer

Problems with web site scraping using zombie.js

I need to do some web scraping. After playing around with different web testing framework, of which most where either too slow (Selenium) or too buggy for my needs (env.js), I decided that zombie.js looks most promising, as it uses a solid set of…
Niklas B.
  • 92,950
  • 18
  • 194
  • 224
10
votes
1 answer

Installing Zombie.js Error: ReferenceError: Set is not defined. What am I doing wrong?

Background: I'm currently reading "Web Development with Node and Express" by Ethan Brown (great book by the way for those learning node and express) and I got stuck on Chapter 5 - Quality Insurance. Everything was running smooth. First I ran the…
esanz91
  • 893
  • 2
  • 12
  • 24
8
votes
1 answer

Zombie.js pressButton Long Callback Delay

I've been trying to figure this out by using a bunch of console.logs and still can't figure out why these load times are so long. So I have the following code in my beforeEach in my Mocha unit test file. browser.fill('email',…
Charlie Fish
  • 18,491
  • 19
  • 86
  • 179
7
votes
2 answers

zombie browser won't open a window after calling open function

tools attempt 1 Darwin 14.3.0 Darwin Kernel Version 14.3.0 io.js v1.8.1 zombie Version 4.0.7 2015-04-10 attempt 2 Linux ubuntuG5 3.13.0-48-powerpc64-smp node.js v0.10.38 zombie Version 3.1.0 2015-03-15 commands: const Browser =…
dmmfll
  • 2,666
  • 2
  • 35
  • 41
7
votes
2 answers

Injecting javascript into zombie.js

Hi I was wondering if there is the ability in node js and zombie js to inject javascript files in to the headless browser, similar to what you can do with phantomjs. For example in phantom js you would do: page.injectJs("amino/TVI.js") I have used…
Charabon
  • 737
  • 2
  • 11
  • 23
1
2 3
14 15