I'm trying to test my generator, which, using composeWith()
, relies on the sub-generator generator-express:
this.composeWith(require.resolve('generator-express/app'), {dirname: this.props.app_name, createDirectory: 'n'});
This is an excerpt from my test with the mock dummy generator:
var deps = [
[helpers.createDummyGenerator(), require.resolve('generator-express/app')]
];
describe('generator-cesium/app Test', () => {
beforeEach(() => {
return helpers.run(path.join(__dirname, '../generators/app'))
.inDir(path.join(__dirname, 'tmp'))
.withPrompts({
viewerContext: '/', // eslint-disable-line camelcase
appName: 'app' // eslint-disable-line camelcase
})
.withGenerators(deps)
});
...
But, I keep getting the following error:
Error [ERR_UNHANDLED_ERROR]: Unhandled error. (TypeError: Cannot read property 'match' of undefined)
at Immediate.setImmediate (node_modules/generator-express/node_modules/yeoman-generator/lib/index.js:406:18)
The error, indicating that the sub-generator is still being executed, leads me to believe that the mock is not actually working?
TypeError: Cannot set property 'resolved' of undefined
when my generator callscomposeWith(...)
, thereby proving this method still is unable to mock the underlying generator dependency. – Infest