This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

natural-interface
TypeScript icon, indicating that this package has built-in type declarations

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.

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i natural-interface

    Weekly Downloads

    1

    Version

    0.1.0-alpha

    License

    MIT

    Unpacked Size

    21.1 kB

    Total Files

    22

    Last publish

    Collaborators

    • mathieueveillard