You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my generator code I'm throwing an exception if a property of opts is not present, but I'm struggling to catch and test that error in my unit tests.
Any advice / suggestions would be great!
Generator:
module.exports = class extends Generator {
constructor(args, opts) {
super(args, opts);
if(typeof opts.props === 'undefined') {
throw new Error('The error message I want to assert on');
}
// ...
}
Test:
describe('abstracted error test', () => {
it('throws an error', (done) => {
helpers
.run(generatorPath)
.withOptions({
props: undefined // The thing I'm expecting to find, when undefined it should error
})
.on('error', (e) => {
// I'd expect to be able to make an assertion on the error here
done();
})
});
});
In my generator code I'm throwing an exception if a property of
opts
is not present, but I'm struggling to catch and test that error in my unit tests.Any advice / suggestions would be great!
Generator:
Test:
yeoman-generator
: 1.0.1yeoman-assert
: 2.2.2yeoman-test
: 1.6.0mocha
: 3.2.0The text was updated successfully, but these errors were encountered: