Skip to content

[Testing] Allow user to enjoy testing generators #498

@SBoudrias

Description

@SBoudrias

I think testing a generator can be a little headache. Sure there's missing documentation, but also, it requires a lot of boilerplate code.

For example, my usual setup for testing a config in Generator-BBB looks like this:

before(function (done) {
  helpers.testDirectory(path.join(__dirname, "temp"), function() {
    this.app = helpers.createGenerator("bbb:app", [
      path.join(__dirname, "../lib/generators/app")
    ]);
    this.app.options["skip-install"] = true;
    helpers.mockPrompt(this.app);
    this.app.run({}, function () { done(); });
  }.bind(this));
});

I believe we should refactor our testing methods to be friendlier to use. I'd suggest this API:

before(function (done) {
  helpers
    .run('../app/index.js')
    .inDir('./temp')
    .withArguments('foo')
    .withOptions({ 'skip-install' : true })
    .withPrompt({ bootstrap: false })
    .then(done);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions