-
Notifications
You must be signed in to change notification settings - Fork 95
No way to use custom mocha ui #84
Comments
It seems like in my testing the mocha.opts file isn't respected by karma-mocha. Putting |
Actually the main cause of this exception is that files: [
'path/to/my-ui.js',
require.resolve('karma-mocha/lib/adapter'),
'path/to/specs/*'
],
client: {
mocha: {
ui: 'my-ui'
}
} |
@stalniy you can create inline adapter for custom mocha reporter and load file before karma-mocha files |
@maksimr this is browser's environment. I need to load files not before mocha.js but right after it (i.e. before |
Think this is related but it would be nice to have a ex. client: {
mocha: {
ui: 'my-ui',
require: [ path.join(__dirname, 'some-script.js') ]
}
} Specifically this would be useful for me to do something like https://labnotes.org/yield-to-the-test-using-mocha-with-es6-generators/ where you could hook into something like |
@stalniy I've had some success getting your https://github.com/stalniy/bdd-lazy-var var initMocha = function (files, mochaConfig) {
var mochaPath = path.dirname(require.resolve('mocha'))
var bddLazyVarPath = path.dirname(require.resolve('bdd-lazy-var'))
files.unshift(createPattern(path.join(__dirname, 'adapter.js')))
files.unshift(createPattern(path.join(bddLazyVarPath, 'bdd_lazy_var_global.js')))
files.unshift(createPattern(path.join(mochaPath, 'mocha.js')))
if (mochaConfig && mochaConfig.reporter) {
files.unshift(createPattern(path.join(mochaPath, 'mocha.css')))
}
} I've generalised this solution, by using @dtothefp idea of a
var initMocha = function (files, mochaConfig) {
files.unshift(createPattern(path.join(__dirname, 'adapter.js')))
if (mochaConfig.require) {
for (var requirePath of mochaConfig.require) {
files.unshift(createPattern(requirePath));
}
}
var mochaPath = path.dirname(require.resolve('mocha'))
files.unshift(createPattern(path.join(mochaPath, 'mocha.js')))
if (mochaConfig && mochaConfig.reporter) {
files.unshift(createPattern(path.join(mochaPath, 'mocha.css')))
}
} Also need to exclude the require array from being sent to mocha in the adapter. Will throw a PR together asap. |
Allow requiring files after mocha is initialised, via karma.conf.js Closes karma-runner#84
Currently it's impossible to use custom mocha ui.
What I want is extra config option which allow to specify which files I want to load before bootstraping mocha (before
adapter.js
)The text was updated successfully, but these errors were encountered: