Jasmine-Node Test Runner

3.0.0 · maintenance · verified Sun Apr 19

Jasmine-node is a command-line utility designed for running Jasmine BDD specifications (specifically version 1.3.1, a forked version from the Karma project) within a Node.js environment without requiring a browser DOM. It provides a simple CLI for executing tests written in JavaScript or CoffeeScript, offering features like automatic test execution on file changes (`--autotest`), colorized output, and optional Growl notifications. The project is explicitly in maintenance mode, and its authors recommend using the official `jasmine` or `jasmine-npm` packages for any new development due to `jasmine-node`'s reliance on an older Jasmine version and limited future development. It supports Node.js versions 10 and 12, with older Node.js versions being deprecated.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates the global installation of `jasmine-node`, the creation of a standard Jasmine spec file (including sync, async, and `ddescribe` examples), and how to execute these tests using the `jasmine-node` command-line interface.

npm install jasmine-node -g

// Create a spec file (e.g., 'spec/example-spec.js')
// NOTE: The filename MUST end with 'spec.js', 'spec.coffee', or 'spec.litcoffee'
describe('A basic Jasmine suite', function() {
  // Synchronous test
  it('should verify true is true', function() {
    expect(true).toBe(true);
  });

  // Asynchronous test with 'done'
  it('should handle async operations', function(done) {
    setTimeout(function() {
      expect('async').toBe('async');
      done();
    }, 50);
  });

  // Using ddescribe to run only this suite (feature from Karma fork)
  ddescribe('A focused suite example', function() {
    it('should be the only test suite executed', function() {
      expect(1).not.toBe(2);
    });
  });
});

// Run tests from the command line in your project's root directory
jasmine-node spec/

view raw JSON →