Search code examples
node.jsnpmmocha.jsyeomanyeoman-generator

npm test fails for custom yeoman generator


I have built a custom yeoman generator. You can find the code at https://github.com/abhishekoza/generator-ratchet.

When I try "npm test", I get following error

  1 passing (454ms)
  1 failing


1) ratchet generator creates expected files:
     Uncaught Error: You don't seem to have a generator with the name mocha:app installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 1 registered generators run yo with the `--help` option.

npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0
The command "npm test" exited with 1.

For full build log, url is "s3.amazonaws.com/archive.travis-ci.org/jobs/26049613/log.txt"

I have added "generator-mocha" as peerDependency in package.json. But when I use, "npm install", it does not install, so I added it under "dependency". "generator-mocha" is installed now, but still I am getting above error.

To build this custom generator, I referred https://github.com/yeoman/generator-gulp-webapp.


Solution

  • I looked at the test.js in the generator-webapp and found that they have an additional bit in the createGenerator call within the beforeEach. Try modifying your test-creation.js, around line 13, to this:

    this.app = helpers.createGenerator('ratchet:app', [
        '../../app', [
            helpers.createDummyGenerator(),
            'mocha:app'
        ]
    ]);