Closed deepu105 closed 5 years ago
Hello @deepu105, I've tried to add generator test, but I keep facing an error, you may help me on this : ` const path = require('path'); const assert = require('yeoman-assert'); const helpers = require('yeoman-test'); const VueJSClientGenerator = require('../generators/client'); const ClientGenerator = require('generator-jhipster/generators/client');
describe('JHipster client generator with blueprint', () => { const blueprintNames = ['generator-jhipster-vuejs', 'vuejs'];
blueprintNames.forEach(blueprintName => {
describe(`generate client with blueprint option '${blueprintName}'`, () => {
before(done => {
helpers
.run(path.join(__dirname, '../generators/client'))
.withOptions({
'from-cli': true,
build: 'gradle',
auth: 'jwt',
db: 'mysql',
skipInstall: true,
blueprint: blueprintName,
skipChecks: true
})
.withGenerators([[VueJSClientGenerator, 'jhipster-vuejs:client']])
.withPrompts({
baseName: 'jhipster',
clientFramework: 'VueJS',
useSass: false,
enableTranslation: true,
nativeLanguage: 'en',
languages: ['fr']
})
.on('end', done);
});
it('creates expected files from jhipster client generator', () => {
//assert.file(expectedFiles.client);
//assert.file(expectedFiles.i18nJson);
});
it('contains the specific change added by the blueprint', () => {
assert.fileContent('package.json', '"vue"');
});
});
});
}); `
Executing such spec using npm run test:unit -- test/*.spec.js
, I get :
Uncaught Error: ERROR! This is a JHipster blueprint and should be used only like jhipster --blueprint vuejs
It seems a constructor issue when running tests. Furthermore, I'm a bit confused by this line in parent client generator : https://github.com/jhipster/generator-jhipster/blob/e528c2f1c5a15bd45759dea371f5d51f7dab0934/generators/client/index.js#L139
Thanks for any help on this one.
@sahbi-ktifa can you look at https://github.com/jhipster/generator-jhipster/tree/master/test/blueprint We should do something like that
I'll be busy this week, if you are still stuck, I can take a look next week.
Hum... I was running a jhipster version prior to Murdos PR... Now that i upgraded my dependency, it starts to work but I'm still facing issues, I'll let you know after I investigated more on this. Thanks
Yoman-test is really hard to apprehend (and debug...). I'm facing several issues:
I looked at kotlin blueprint but there is no test as well. Is there a blueprint repo where such tests run ? I pushed my work here : https://github.com/sahbi-ktifa/jhipster-vuejs/tree/feature/blueprint-test
Thanks for any help
@murdos have you got any idea on this? Maybe an example with tests on a blueprint
Here's a working example for the server generator:
const helpers = require('yeoman-test');
helpers
.run('generator-jhipster/generators/server') // <= here we have the jhipster subgenerator
.withOptions({ skipInstall: true, blueprint: 'blueprintName', skipChecks: true })
.withGenerators([
[
require('../generators/server/index.js'), // eslint-disable-line global-require
'jhipster-blueprintName:server',
path.join(__dirname, '../generators/server/index.js') // <= and here the blueprint subgenerator
]
])
.withPrompts(prompts)
.on('end', done);
This is what I plan to add to generator-jhipster-blueprint (https://github.com/jhipster/generator-jhipster-blueprint/issues/7), probably this week-end.
@sahbi-ktifa : could you rebase your branch and push a 1st version ? (PR or directly to a branch here) So I can take a look, as it's very important here to test all options.
@pascalgrimaud I've pushed to https://github.com/sahbi-ktifa/jhipster-vuejs/tree/feature/test-blueprint a simple test. Can't make it work yet but I haven't look it up through for few weeks
Thanks @sahbi-ktifa, I will try to have a look
I think this is closely tied to main generator behavior as generation fails right now in current test. I suspect a minor improvement could help up on that, thus @murdos already demonstrated a working example
It works on my machine. I need to write all possible config and will PR
What did you change ? :)
Helped by blueprint tests, as suggested by @murdos but I needed to do some changes to make it work. Will finish it tonight or during this WE.
Great!
Bounty claimed https://opencollective.com/generator-jhipster/expenses/6152
Lets add some unit tests similar to https://github.com/jhipster/generator-jhipster/pull/8365/files