0.1.4 • Published 2 years ago

jasmine-theories v0.1.4

Weekly downloads
51
License
ISC
Repository
github
Last release
2 years ago

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"
0.1.4

2 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

8 years ago

0.0.1

9 years ago