Skip to content

The chai testing framework, configured with dirty-chai, chai-string and chai-equal-jsx.

License

Notifications You must be signed in to change notification settings

epsitec-sa/mai-chai

Repository files navigation

mai-chai

The chai testing framework works hand in hand with mocha. It is configured by default with following plugins:

mai-chai also includes configuration files which will be written into the ./test folder of the including project:

  • mocha.opts → registers Babel as the compiler and requires the ./test/test-helper.js file in every test.
  • test-helper.js → configures the global document, window and navigator objects.

And for Wallaby.js users, mai-chai comes with a default configuration file.

Conventions

mai-chai follows these conventions:

  • ./src → source code under test.
  • ./src.test → source code for the tests.
  • ./test → mocha configuration files.

Installing mai-chai

First install mai-chai:

npm install mai-chai --save-dev

This will also install mocha, chai, chai-as-promised, chai-asserttype, chai-equal-jsx, chai-spies, chai-string and dirty-chai.

Using mai-chai

Import expect from mai-chai, as you would from chai:

import {expect} from 'mai-chai';

and then write your BDD assertions with methods rather than properties, such as:

expect (true).to.be.true ();
foo.should.be.ok ();

or use the various assertions added by chai-string and spy on methods with chai-spies.

Configuring Wallaby.js

mai-chai provides a default Wallaby.js configuration file. If you stick to the conventions of mai-chai no other setup or configuration is required. Just point Wallaby.js to wallaby.conf.js.

Included plugins

See also Algolia's react-element-to-jsx-string which is used by chai-equal-jsx and provides the logic needed to convert a ReactElement to the corresponding JSX string.

Utility functions

  • clock() → perf, starts a high resolution timer which can be used to measure performance; it returns an opaque object.
  • clock(perf) → ms, returns the number of milliseconds elapsed.

About

The chai testing framework, configured with dirty-chai, chai-string and chai-equal-jsx.

Resources

License

Stars

Watchers

Forks

Packages

No packages published