chai - Writing sad path test for Yeoman generator -


i have yeoman generator requires argument. want write test confirm throws error if generator called without arguments.

i have tried many variations similar following code.

'use strict'; var path = require('path'); var assert = require('yeoman-assert'); var helpers = require('yeoman-test'); var chai_assert = require('chai').assert;   describe('my yeoman generator', function(){   it('will barf without arguments', function(done) {     this.timeout(0);     var fn = function() {       helpers.run(path.join(__dirname, '../generators/app'))         .on('end', done);     };     chai_assert.throws(fn);   }); }); 

chai's assert.throws doesn't catch exception 1 thrown. i'm not sure why error thrown chai doesn't catch it. appreciated.

the error message given is

1) yeoman generator barf without arguments:  assertionerror: expected [function: fn] throw error   @ function.assert.throws (node_modules/chai/lib/chai/interface/assert.js:1120:52)   @ context.<anonymous> (test/test-app.js:21:17)  2) yeoman generator default "before all" hook:  uncaught error: did not provide required argument project_name!   @ constructor.<anonymous> (node_modules/yeoman-generator/lib/base.js:387:33)   @ array.foreach (native)   @ constructor.base.checkrequiredargs (node_modules/yeoman-generator/lib/base.js:383:19)   @ constructor.argument (node_modules/yeoman-generator/lib/base.js:348:8)   @ new constructor (generators/app/index.js:7:10)   @ environment.instantiate (node_modules/yeoman-test/node_modules/yeoman-environment/lib/environment.js:336:10)   @ environment.create (node_modules/yeoman-test/node_modules/yeoman-environment/lib/environment.js:313:15)   @ runcontext._run (node_modules/yeoman-test/lib/run-context.js:90:29)   @ runcontext.<anonymous> (node_modules/yeoman-test/lib/run-context.js:58:10)   @ node_modules/yeoman-test/node_modules/lodash/lodash.js:5152:35   @ node_modules/yeoman-test/lib/index.js:94:5   @ next (node_modules/yeoman-test/node_modules/rimraf/rimraf.js:74:7)   @ cb (node_modules/yeoman-test/node_modules/rimraf/rimraf.js:110:9)   @ node_modules/yeoman-test/node_modules/rimraf/rimraf.js:136:14   @ fsreqwrap.oncomplete (fs.js:111:15) 


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -