-
Notifications
You must be signed in to change notification settings - Fork 138
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
How does this work? #123
Comments
Hey @alayek, I only understand enough of workshopper to get by, but in that case that's enough. I'm writing a D3 workshopper, using mocha and chai to test the solutions (+ ES6, jsdom and D3, but that's less relevant). You can have a look at the relevant code here: https://github.com/ThibWeb/testdrived3/blob/master/src/lib/runner.js#L47 This comes down to:
exercise.addSetup(function(mode, callback) {
const mocha = new Mocha();
mocha.addFile(path.join(this.dir, 'spec.js'));
runFunction(global.submission);
mocha.run((failures) => {
this.failures = failures;
callback(null, true);
});
});
exercise.addVerifyProcessor(function(callback) {
const i18n = exercise.__.bind(exercise);
const passed = this.failures === 0;
if (passed) {
this.emit('pass', i18n('test.pass'));
} else {
this.emit('fail', i18n('test.fail'));
}
callback(null, passed);
}); I have no idea if those are the proper hooks for this scenario, and I'm passing a global variable around that contains the user's solution, but hey it works! I stumbled upon this pattern while creating a PR for a React workshopper: https://github.com/asbjornenge/thinking-in-react. I intend to extract a "jsdom ES6 mocha workshopper" boilerplate from this code once I'm done with it. Edit: done! The boilerplate is available at https://github.com/ThibWeb/workshopper-mocha-boilerplate. |
Hi, I would like to know how workshopper module works. I checked the promise-it-won't-hurt nodeschool exercise, and it seems to me that workshopper takes the student's submission, and solution provided - then compares both.
Is there any way for someone to use this workshopper module without providing solutions directly, and rather just provide test cases for expected solution in, say, Mocha and Chai JS?
I know it's not an issue, but I could not find any mailing list. Apologies for posting it under issues.
The text was updated successfully, but these errors were encountered: