mocha

v5.0.2arrow_drop_down
v8.1.3
v5.0.2
v0.0.17
v0.0.16
v0.0.15
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
110,243
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
4 years ago
SIZE
N/A
A bit testing environment for mocha.
5 contributors
Install mocha as a package?
Copied
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
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
};
Help and resources