Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

mocha

v0.0.7arrow_drop_down
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
93,669
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
2 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.dev
Files
index.js
24 Lines(22 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
import {JSDOM} from 'jsdom';
import convertMochaFormatToBitFormat from './resultsAdapter';
import JSONReporter from './jsonReporter';
const Mocha = require('mocha');
const { document } = new JSDOM('<!doctype html><html><body></body></html>').window;

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,
  globals: {
    window: document.defaultView,
    navigator: {userAgent: 'node.js'}
  }
};