Closed SBoudrias closed 8 years ago
A potential solution I've come to think about is to mock the module require (with for example proxyquire
).
We might to extract our test utilities to a separate module at this point. These are becoming fairly large and are impacting end user download time (who don't care about testing).
another solution i use is to define an 'testmode'
option in the generator, that defaults to false
and then use the following code when calling the subgenerator:
this.composeWith('xxx',
{} ,
this.options.testmode ? null : {local: require.resolve('generator-xxx'})
Then when you run the generator in your test, set the option 'testmode'
to true with withOptions
Reopened under https://github.com/yeoman/yeoman-test/issues/16
When using composition with a local path (
composeWith('gen:app', { local: 'local/path' })
), it ignores/bypass the generators mocks we setup on the RunContext with#withGenerators()
as it requires/register the generator directly.This should probably be fixed, I'm unsure about the correct solution ATM.