When using CoderPad to write code in the browser, say your on the go and just need to write some code, and that code happens to be JavaScript and you want to run a Mocha test here is what you need to do:
'use strict';
const { expect } = require('chai');
const Mocha = require('mocha');
const mocha = new Mocha({ui: 'bdd'});
// CODE ///////////////
// write your code here, test it below
// TEST ////////////////
// Bit of a hack, sorry!
mocha.suite.emit('pre-require', this, 'solution', mocha);
describe('My Tests', () => {
it('should run', () => {
expect(2).to.equal(2);
});
});
mocha.run(function() {});
I snagged this from here