diff --git a/src/EnhancedMocha.js b/src/EnhancedMocha.js deleted file mode 100644 index 6431cd0..0000000 --- a/src/EnhancedMocha.js +++ /dev/null @@ -1,56 +0,0 @@ -import Mocha from 'mocha'; - -export default class EnhancedMocha extends Mocha { - loadFiles(fn) { - const { suite } = this; - - suite.suites.length = 0; - suite.tests.length = 0; - - try { - const [file] = this.files; - if (module.hot) { - module.hot.accept(file, () => { - if (this.watching) { - if (!this.running) this.run(); - else this.outdated = true; - } - }); - } - suite.emit('pre-require', global, file, this); - // eslint-disable-next-line global-require, import/no-dynamic-require - suite.emit('require', require(file), file, this); - suite.emit('post-require', global, file, this); - } catch (e) { - suite.addTest( - new Mocha.Test('fix test errors', () => { - throw e; - }) - ); - } - - if (fn) { - fn(); - } - } - - watch() { - this.outdated = false; - this.running = true; - this.watching = true; - - // reinit ui to fix ui bugs - this.ui(this.options.ui); - - // run the tests - this.run((/* failures */) => { - this.running = false; - if (this.outdated) this.watch(); - }); - - if (module.hot) { - // Don't exit the process - setInterval(() => {}, 100000); - } - } -} diff --git a/src/index.js b/src/index.js index 6d5d5ed..7bd17bc 100644 --- a/src/index.js +++ b/src/index.js @@ -4,7 +4,6 @@ import validateOptions from 'schema-utils'; import schema from './options.json'; const startScriptPath = require.resolve('./start.js'); -const enhancedMochaPath = require.resolve('./EnhancedMocha.js'); const mochaJs = require.resolve('mocha/mocha.js'); const mochaCss = require.resolve('mocha/mocha.css'); const { stringify } = JSON; @@ -44,17 +43,6 @@ export function pitch(req) { source.push('\t\treport && report.parentNode.removeChild(report);'); source.push('\t});'); source.push('}'); - } else if (this.target === 'node') { - source.push( - `import EnhancedMocha from ${stringify(`!!${enhancedMochaPath}`)};` - ); - source.push( - `const mocha = new EnhancedMocha({reporter: ${stringify( - options.reporter || 'spec' - )}});` - ); - source.push(`mocha.addFile(${stringify(`!!${req}`)});`); - source.push('mocha.watch();'); } else { throw new Error(`Unsupported target environment ${this.target}`); }