0.0.1 • Published 4 months ago

jasmine-jsdom-runner v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

Jasmine JSDom Runner

A zero-configuration test runner for Jasmine with JSDom environment.

Features

  • Zero configuration needed - works right out of the box
  • Automatically finds and runs *spec.js files
  • Pre-configured JSDom environment for browser testing
  • Supports custom Jasmine configuration

Installation

Global Installation

npm install -g jasmine-jsdom-runner

NPX Usage

npx jasmine-jsdom-runner

How It Works

  1. Creates a JSDom environment with all necessary browser globals
  2. Automatically searches for *spec.js files in your project
  3. Configures and runs Jasmine with these spec files
  4. Displays results in a formatted console output

Configuration (Optional)

By default, no configuration is required. The tool will:

  • Search for *spec.js files in your project
  • Set up a basic JSDom environment
  • Run tests with default Jasmine settings

If you want custom configuration, you can add a jasmine.json file to your project root:

{
  "spec_dir": ".",
  "spec_files": ["**/*spec.js"],
  "helpers": ["helpers/**/*.js"],
  "stopSpecOnExpectationFailure": false,
  "random": false
}

Example Usage

  1. Create test files with the naming pattern *spec.js
  2. Write your Jasmine tests as usual
  3. Run npx jasmine-jsdom-runner

Sample Test

// hello.spec.js
describe("Hello", function () {
  it("should say hello", function () {
    expect("Hello World").toContain("Hello");
  });

  it("should work with DOM", function () {
    document.body.innerHTML = '<div id="test">Test Element</div>';
    expect(document.getElementById("test").textContent).toBe("Test Element");
  });
});

License

MIT