A custom element for running mocha and chai chai tests, where each HTML file is a separate test suite.
<html>
<head>
<title>My test suite</title>
<link rel="import" href="path/to/mocha-test/mocha-test.html">
</head>
<body>
<mocha-test>
<template>
<script>
describe('Running tests', function(){
it('has never been this easy!', function(){
assert.ok(true);
});
});
</script>
</template>
</mocha-test>
</body>
</html>
Install with either NPM or Bower:
npm install mocha-test --save-dev
bower install mocha-test --save-dev
Use webcomponentsjs to polyfill the web component APIs in incompatible browsers. Then use the <mocha-test>
tag.
By default mocha-test assumes it is running within node_modules
or bower_components
and will find mocha and chai in sibling folders.
If you have put mocha-test.html somewhere else, or your versions of mocha/chai are in non-standard locations you can customize their path with these attributes:
<mocha-test mocha-path="./lib/mocha" chai-path="./lib/chai">
...
</mocha-test>
Note that this is the path to the mocha/chai folder, not their JavaScript files.
This attribute lets you control which user-interface is used. Either bdd, tdd or exports are valid options. bdd is the default.
<mocha-test ui="tdd">...</mocha-test>
BSD 2 Clause