How to use the yeoman-test.setUpTestDirectory function in yeoman-test

To help you get started, we’ve selected a few yeoman-test examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yeoman / generator / test / base.js View on Github external
describe('Base', () => {
  beforeEach(helpers.setUpTestDirectory(tmpdir));

  beforeEach(function() {
    this.env = yeoman.createEnv([], { 'skip-install': true }, new TestAdapter());
    makeDir.sync(resolveddir);
    this.Dummy = class extends Base {};
    this.Dummy.prototype.exec = sinon.spy();

    this.dummy = new this.Dummy(['bar', 'baz', 'bom'], {
      foo: false,
      something: 'else',
      // Mandatory options, created by the `env#create()` helper
      resolved: resolveddir,
      namespace: 'dummy',
      env: this.env,
      'skip-install': true
    });
github DefinitelyTyped / DefinitelyTyped / types / yeoman-test / yeoman-test-tests.ts View on Github external
import * as fs from 'fs';
import * as path from 'path';
import * as helpers from 'yeoman-test';
import Generator = require('yeoman-generator');

declare const env: any;
declare const generator: Generator;
declare function before(done: (...args: any[]) => void): void;

// helpers.setUpTestDirectory()
before(helpers.setUpTestDirectory('dir'));

// helpers.gruntfile()
before(done => helpers.gruntfile({foo: 'bar'}, done));

// helpers.testDirectory()
helpers.testDirectory(path.join(__dirname, './temp'), () => {
	fs.writeFileSync('testfile', 'Roses are red.');
});

// helpers.mockPrompt()
helpers.mockPrompt(generator, {foo: 'bar'});

// helpers.restorePrompt()
helpers.restorePrompt(generator);

// helpers.mockLocalConfig()
github yeoman / generator / test / actions.js View on Github external
describe('generators.Base (actions/actions)', function () {
  before(helpers.setUpTestDirectory(tmpdir));

  beforeEach(function () {
    var env = this.env = generators([], {}, new TestAdapter());
    var Dummy = generators.Base.extend({
      exec: function () {}
    });
    env.registerStub(Dummy, 'dummy');
    this.dummy = env.create('dummy');
    this.fixtures = path.join(__dirname, 'fixtures');
    this.dummy.sourceRoot(this.fixtures);
    this.dummy.foo = 'bar';
  });

  describe('#sourceRoot()', function () {
    it('updates the "_sourceRoot" property when root is given', function () {
      this.dummy.sourceRoot(this.fixtures);
github yeoman / generator / test / remote.js View on Github external
describe('generators.Base#remote()', function () {
  before(helpers.setUpTestDirectory(tmpdir));

  beforeEach(function () {
    this.env = yeoman.createEnv([], {}, new TestAdapter());
    var Dummy = generators.Base.extend({
      exec: sinon.spy()
    });
    this.env.registerStub(Dummy, 'dummy');
    this.dummy = this.env.create('dummy');
    nock('https://github.com')
      .get('/yeoman/generator/archive/master.tar.gz')
      .replyWithFile(200, path.join(__dirname, 'fixtures/testRemoteFile.tar.gz'));
  });

  it('remotely fetch a package on github', function (done) {
    this.dummy.remote('yeoman', 'generator', done);
  });
github yeoman / generator / test / storage.js View on Github external
describe('Storage', () => {
  beforeEach(helpers.setUpTestDirectory(tmpdir));

  beforeEach(function() {
    this.beforeDir = process.cwd();
    this.storePath = path.join(tmpdir, 'new-config.json');
    this.memFs = env.createEnv().sharedFs;
    this.fs = FileEditor.create(this.memFs);
    this.store = new Storage('test', this.fs, this.storePath);
    this.store.set('foo', 'bar');
  });

  afterEach(function() {
    const json = this.fs.read(this.storePath);
    assert.ok(json.endsWith('\n'));
    assert.ok(!json.endsWith('\n\n'));
    rm(this.storePath);
    process.chdir(this.beforeDir);