We’re excited to announce Bit’s new home at bit.dev!Learn more

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
70,272
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
3 months ago
subject
A bit testing environment for mocha.
3 contributors
Like
Use mocha in your project ?
Copied
npm i @bit/bit.envs.testers.mocha
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
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
};