Karma with Mocha Testing Framework
Qualified has support for testing in-browser code using Karma with Mocha.
There is very little changes necessary from testing normal code, except your code will be run inside a PhantomJS headless browser, enabling you to test browser-specific events.
Language Version
All code run in the browser is transpiled via Babel, so you can safely use ES2015 code.
Using Mocha
Mocha in Karma works the same as the normal Mocha Testing Framework (BDD), with one exception: Chai will already be loaded for you, with expect
, should
, and assert
all available, no require()
necessary.
Note on Chai Failure Reporting
By default Chai truncates objects and arrays over
40
characters in length. If you want to show longer objects (especially arrays) to candidates, you should add the following to yourpreloaded
section:
// How many characters to show before truncating long objects? 0 means no truncating. chai.config.truncateThreshold = 1000;
Including External Libraries
There is a lightweight library inclusion feature, based on comments in the Preloaded section. Including comments like the following enables automatic inclusion of well-known libraries.
// @include-external [email protected]
We only support the following:
- `[email protected]` - AngularJS core libraries, v1.2.x
- `[email protected]` - AngularJS core libraries, v1.3.x
- `angu[email protected]` - AngularJS core libraries, v1.4.x
- `[email protected]` - AngularJS core libraries, v1.5.x
- `[email protected]` - AngularJS core libraries, v1.6.x
Related Articles
-
Jest Testing Framework
Information for using Jest -
Karma with Mocha Testing Framework (TDD)
Information about the Karma with Mocha testing framework -
Mocha Testing Framework (BDD)
Information about the Mocha testing framework -
Mocha Testing Framework (TDD)
Information about the Mocha testing framework -
Qualified Testing Framework
Help for the Qualified Testing Framework under JavaScript