What is the difference between Zombie.js and Jasmine?

574 Views Asked by At

May I know what is the difference between Zombie.js and Jasmine? are they both frameworks?

1

There are 1 best solutions below

1
try-catch-finally On

Jasmine is a unit test framework for BDD (behavior driven development). It requires an execution environment like NodeJs or a browser like Firefox, Chrome, IE, PhantomJS etc. to run (and to provide the environment for the code under test). Jasmine provides the test execution and assertion infrastructure (that's the describe(), it(), expect()).

Zombie.js is an emulated, headless browser. It's a browser on its own plus an interaction API for itself. It's like Selenium/Webdriver. It's using jsdom under its hood to provide the APIs browsers usually provide. Zombie.js requires a test execution and assertion infrastructure (like Mocha + should.js or even Jasmine).


  • With Jasmine you write tests on a module or group-of-modules level. But usually not on an application level

  • With Zombie.js you interact with a website (served by a server) through an interaction API.

  • With Jasmine you make fine grained assertions on the output or events created for certain input - on the module level.

  • With Zombie.js you interact with the whole application (or website).

  • With Jasmine you test only the Javascript part.

  • With Zombie.js you test the the frontent + backend. Though you might be able to mock away and intercept server interaction (maybe, I'm not familar with it).

  • With Jasmine you call a method/function, pass a parameter and test the return value and events

  • With Zombie.js you load a page and fill a form and test the output

  • With Jasmine you need to run the tests in the proper execution envrionment (like Firefox, Chrome, ...)

  • With Zombie.js you pages runs in a new execution environment

  • With Jasmine you can test in browsers (consumers use) with their typical quirks

  • With Zombie.js you test you application in a new browser with new quirks


Jasmine example:

    // spy on other module to know "method" was called on it
    spyOn(otherModule, "method");

    // create module
    let module = new Module(otherModule),
        returnValue;

    // calls otherModule.method() with the passed value too; always returns 42
    returnValue = module(31415);

    // assert result and interaction with other modules
    expect(returnValue).toBe(42);
    expect(otherModule.method).toHaveBeenCalledWith(31415);

Zombie.js example:

    // create browser
    const browser = new Browser();
    // load page by url
    browser.visit('/signup', function() {
        browser
            // enter form data by name/CSS selectors
            .fill('email', '[email protected]')
            .fill('password', 'eat-the-living')
            // interact, press a button
            .pressButton('Sign Me Up!', done);
    });

    // actual test for output data
    browser.assert.text('title', 'Welcome To Brains Depot');

Zombie.js, like Webdriver/Selenium, is no replacement for a unit testing framework like Jasmine, Mocha.