jasmine-theories
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

jasmine-theories

This lib adds theories to jasmine. Theories make it possible to run the same testing code with varying inputs. It should only be used when a case holds true for a variety of similar values, such as in the example provided below.

Let's build a spec theory, using theoretically.it:

const theoretically = require("jasmine-theories");

describe("NumberStack", function() {
  theoretically.it("fails if the inserted value is %s (not a number)", [ null, false, new Error("hello"), "str" ], function(insertedValue) {
    const stack = new NumberStack();
    expect(function() {
      stack.push(insertedValue);
    }).toThrow();
  });
});

We would want this output if the cases false and new Error("hello") fails:

Failed: NumberStack fails if the inserted value is false (not a number)
Failed: NumberStack fails if the inserted value is Error: hello (not a number)

The library also supports theoretically.xit, which adds pending tests to the spec.

For use in typescript use classic import statement:

import theoretically from "jasmine-theories"

Package Sidebar

Install

npm i jasmine-theories

Weekly Downloads

55

Version

0.1.4

License

ISC

Unpacked Size

5.2 kB

Total Files

6

Last publish

Collaborators

  • hypesystem