mocha

v0.0.17arrow_drop_down
v0.0.17
v0.0.14
v0.0.13
v0.0.12
v0.0.11
v0.0.10
v0.0.9
v0.0.8
v0.0.7
v0.0.6
v0.0.5
v0.0.4
v0.0.3
v0.0.2
v0.0.1
STATUS
Passing
DOWNLOADS
63,552
LICENSE
MIT
VISIBILITY
Public
subject
Bit testing environment for testing of bit components using Mocha.
3 contributors
Like
Use mocha in your project ?
Copied
npm i @bit/bit.envs.testers.mocha

Configure Bit as a scoped registry to install components with NPM.Learn more

npm config set '@bit:registry' https://node.bitsrc.io
Don't show this again
Files
  • baseReporter.js
  • index.js
  • jsonReporter.js
  • mochaHooksNames.js
  • readme.md
  • resultsAdapter.js
  • compilers/babel@0.0.7
index.js
27 Lines(24 sloc)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import {JSDOM} from 'jsdom';
import convertMochaFormatToBitFormat from './resultsAdapter';
import Mocha from 'mocha';
import JSONReporter from './jsonReporter';
import 'ignore-styles';

const { document } = new JSDOM('<!doctype html><html><body></body></html>').window;
global.window = document.defaultView
global.document = document
global.navigator = {
  userAgent: 'node.js'
};

const run = (specFile) => {
  return new Promise((resolve) => {
    const mocha = new Mocha({ reporter: JSONReporter });
    mocha.addFile(specFile);
    mocha.run()
    .on('end', function() { // eslint-disable-line
      return resolve(convertMochaFormatToBitFormat(this.testResults));
    });
  });
};

export default {
  run
};