Imagine if you could run your generated tests within your yeoman generator tests, just as simple as dreaming within a dream... Lol
$ npm install --save-dev yo-inception
or
$ yarn add --dev yo-inception
More examples coming soon...
describe('run generated tests', () => {
let inception;
beforeAll(done => {
inception = new Inception(path.join(__dirname, 'tempDir'));
inception.copyPackageJson(
path.join(__dirname, '../path/to/generator/templates/_package.json'), {
someAnswer: true
}
);
return inception.npmInstall()
.then(() => inception.runGen(path.join(__dirname, '../path/to/generator'), { someAnswer: true }))
.then(() => done());
});
it('should pass', async () => {
await expect(inception.runAsyncCommand('npm', ['run', 'test-pass'])).resolves.toBe(0);
});
afterAll(() => {
inception.clean();
});
});
const Inception = require('yo-inception');
const path = require('path');
const inception = new Inception(path.join(__dirname, 'tempDir');
inception.copyPackageJson(
path.join(__dirname, '../path/to/generator/_package.json'), {
someAnswer: true
});
const Inception = require('yo-inception');
const path = require('path');
const inception = new Inception(path.join(__dirname, 'tempDir');
// with npm
inception.npmInstall();
// or with yarn
inception.yarnInstall();
const Inception = require('yo-inception');
const path = require('path');
const inception = new Inception(path.join(__dirname, 'tempDir');
inception.runGen(path.join(__dirname, '../path/to/gen'), { someAnswer: true })
.then(() => inception.runAsyncCommand(['gulp'], ['test']));
const Inception = require('yo-inception');
const path = require('path');
const inception = new Inception(path.join(__dirname, 'tempDir');
inception.clean(); // removes tempDir