Permalink
Browse files

feat(serenity-mocha): A compiler can be registered as a configuration…

… parameter
  • Loading branch information...
jan-molak committed Feb 8, 2017
1 parent ab36827 commit 02a0c6eb3e6f53f6ee7bdcacc5df02c5360bd447
@@ -1,5 +1,4 @@
'use strict';
require('ts-node/register');
var path = require('path'),
src = path.resolve(path.relative(process.cwd(), __dirname), '../../../src'),
@@ -21,7 +20,8 @@ exports.config = {
specs: [ 'spec/**.ts' ],
mochaOpts: {
ui: 'bdd'
ui: 'bdd',
compiler: 'ts:ts-node/register',
},
capabilities: {
@@ -24,6 +24,11 @@ export interface MochaConfig {
'tap' |
'xunit';
/**
* Register a custom compiler, such as 'ts:ts-node/register'
*/
compiler?: string;
/**
* Timeout in milliseconds
*/
@@ -16,9 +16,10 @@ export class MochaTestFramework implements TestFramework {
constructor(private config: MochaConfig) {
const Mocha = attemptToRequire('mocha');
this.mocha = new Mocha(config);
this.registerCompilerIfNeeded(config.compiler);
this.mocha.suite.on('pre-require', function () {
let g: any = global;
@@ -64,4 +65,12 @@ export class MochaTestFramework implements TestFramework {
});
});
}
private registerCompilerIfNeeded(compiler: string): void {
if (!! compiler && !! ~compiler.indexOf(':')) {
let [ , module ] = compiler.split(':');
attemptToRequire(module);
}
}
}

0 comments on commit 02a0c6e

Please sign in to comment.