Need private packages and team management tools?Check out npm Teams »

natural-interface

0.1.0-alpha • Public • Published

natural-interface

In the context of tests using a page model (see here and here), natural-interface allows you to write tests in natural language.

natural-interface has no effect on methods used during the "arrange" or "act" steps of the test. It is relevant only for the "assert" step. Also, natural-interface works with every test runner that relies on exceptions internally.

Installation

npm i -D natural-interface

Usage

Assuming the following page model:

class Model {
  expectBooleanToBeTrue = b => {
    expect(b).toBe(true);
  };
 
  expectBooleanToBeFalse = b => {
    expect(b).toBe(false);
  };
}

and the following test:

it("should make assertions on booleans", () => {
  const model = new Model();
  model.expectBooleanToBeTrue(true);
  model.expectBooleanToBeFalse(false);
});

it is now possible to write:

class Model {
  booleanToBeTrue = b => {
    expect(b).toBe(true);
  };
}
import { withNaturalLanguage } from "natural-interface";
 
it("should make assertions on booleans", () => {
  const model = withNaturalLanguage(new Model());
  model.expect.booleanToBeTrue(true);
  model.expect.not.booleanToBeTrue(false);
});
 

This, of course, if a contrived example. Making assertions on booleans whithout business context is not a real world scenario.

Install

npm i natural-interface

DownloadsWeekly Downloads

0

Version

0.1.0-alpha

License

MIT

Unpacked Size

21.1 kB

Total Files

22

Last publish

Collaborators

  • avatar