Skip to content

Lets you run the same test with varying inputs. Like theories in XUnit.

License

Notifications You must be signed in to change notification settings

hypesystem/jasmine-theories

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"

About

Lets you run the same test with varying inputs. Like theories in XUnit.

Resources

License

Stars

Watchers

Forks

Packages

No packages published