-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing Mocha with wallaby #1490
Comments
@boneskull
Yes, wallaby tries to load mocha from It should be possible to run mocha unit tests with mocha in wallaby with few changes in the config:
So the following wallaby config should work for you: 'use strict';
module.exports = () => {
return {
files: [
'index.js', 'lib/**/*.js', 'test/setup.js',
{
pattern: 'test/node-unit/**/*.fixture.js',
instrument: false
}, {
pattern: 'test/unit/**/*.fixture.js',
instrument: false
}
],
filesWithNoCoverageCalculated: ['test/**/*.fixture.js'],
tests: [
'test/unit/**/*.spec.js', 'test/node-unit/**/*.spec.js'
],
env: {
type: 'node',
runner: 'node'
},
workers: {recycle: true},
testFramework: {type: 'mocha', path: __dirname},
setup (wallaby) {
// running mocha instance is not the same as mocha under test,
// running mocha is the project's source code mocha, mocha under test is instrumented version of the source code
const runningMocha = wallaby.testFramework;
runningMocha.timeout(200);
// to expose it/describe etc. on the mocha under test
const mochaUnderTest = new (require('./'))();
mochaUnderTest.suite.emit('pre-require', global, '', mochaUnderTest);
// to make test/node-unit/color.spec.js pass, we need to run mocha in the project's folder context
const childProcess = require('child_process');
const execFile = childProcess.execFile;
childProcess.execFile = function () {
let opts = arguments[2];
if (typeof opts === 'function') {
opts = {};
Array.prototype.splice.call(arguments, 2, 0, opts);
}
opts.cwd = wallaby.localProjectDir;
return execFile.apply(this, arguments);
};
require('./test/setup');
},
debug: true
};
}; |
As discussed at wallabyjs/public#1490 (comment)
As discussed at wallabyjs/public#1490 (comment)
As discussed at wallabyjs/public#1490 (comment)
Issue description or question
We have this test. It's simply supposed to grab the
main
file (as inpackage.json
) from the project, then use its exported functions to run tests.Wallaby reports this:
Debug window gives a longer trace:
Changing worker count seems to have no positive effect.
Wallaby.js configuration file
There are a couple more problems that I'm suspecting are of the same nature; certain methods being undefined such as
this.skip()
orthis.retries()
being unavailable, which were recent changes in Mocha.It should be noted that if Wallaby is looking for
node_modules/mocha
, it ain't there. But settingNODE_PATH=${__dirname}
causes the following to repeat over and over:Code editor or IDE name and version
WebStorm 2017.3.3
Build #WS-173.4301.22, built on January 15, 2018
Licensed to Mocha /
Subscription is active until November 2, 2018
For non-commercial open source development only.
JRE: 1.8.0_152-release-1024-b11 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.13.2
The text was updated successfully, but these errors were encountered: