• Stars
    star
    44
  • Rank 634,578 (Top 13 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 9 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Test utilities for Yeoman generators

yeoman-test

NPM version NPM Test Integration Build Dependency Status Coverage percentage

Test utilities for Yeoman generators

Installation

$ npm install --save-dev yeoman-test

Install target environment and generator:

$ npm install --save-dev yeoman-generator@xxx yeoman-environment@xxx

Usage

Usage using the convenience last RunResult instance:

import helpers, { result } from 'yeoman-test';

describe('generator test', () => {
  describe('test', () => {
    beforeEach(async () => {
      await helpers
        .run(                   // instantiates RunContext
          'namespace',             // namespace or generator
          {},                      // test options
          {}                       // environment options
        )
        [.cd(dir)]                  // runs the test inside a non temporary dir
        [.onTargetDirectory(dir => {})        // prepares the test dir
        [.withGenerators([])]       // registers additional generators
        [.withLookups({})]          // runs Environment lookups
        [.withOptions({})]          // passes options to the generator
        [.withLocalConfig({})]      // sets the generator config as soon as it is instantiated
        [.withAnswers()]            // simulates the prompt answers
        [.withMockedGenerators(['namespace', ...])]      // adds a mocked generator to the namespaces
        [.withFiles({
          'foo.txt': 'bar',
          'test.json', { content: true },
        })]                         // add files to mem-fs
        [.withYoRc({ 'generator-foo': { bar: {} } })]    // add config to .yo-rc.json
        [.withYoRcConfig('generator-foo.bar', { : {} })] // same as above
        [.commitFiles()]            // commit mem-fs files to disk
        [.onGenerator(gen => {})]   // do something with the generator
        [.onEnvironment(env => {})]; // do something with the environment

      [await result.create('another-generator').run();] // instantiates a new RunContext at the same directory
    );

    it('runs correctly', () => {
      // runs assertions using mem-fs.
      [result.assertFile('file.txt');]
      [result.assertNoFile('file.txt');]
      [result.assertFileContent('file.txt', 'content');]
      [result.assertEqualsFileContent('file.txt', 'content');]
      [result.assertNoFileContent('file.txt', 'content');]
      [result.assertJsonFileContent('file.txt', {});]
      [result.assertNoJsonFileContent('file.txt', {});]
    });
  });
});

Generator compose:

import assert from 'assert';
import helpers, { result } from 'yeoman-test';

describe('my-gen', () => {
  before(() => helpers.run('my-gen').withMockedGenerator(['composed-gen']));
  it('should compose with composed-gen', () => {
    assert(result.mockedGenerators['composed-gen'].calledOnce);
  });
});

Generic test folder:

import helpers, { result } from 'yeoman-test';

describe('generic test', () => {
  before(() => helpers.prepareTemporaryDir());
  it('test', () => {
    result.assert...;
  });
});

See our api documentation for latest yeoman-test release.

See our api documentation for yeoman-test 5.0.1. Use 5.x for yeoman-environment 2.x support.

See our api documentation for yeoman-test 2.x.

See our documentation for yeoman-test 2.x.

License

MIT ยฉ The Yeoman Team

More Repositories

1

yeoman

Yeoman - a set of tools for automating development workflow
10,081
star
2

generator-angular

Yeoman generator for AngularJS
JavaScript
5,729
star
3

yo

CLI tool for running Yeoman generators
JavaScript
3,835
star
4

generator-webapp

A gulp.js generator for modern webapps
JavaScript
3,770
star
5

generator-chrome-extension

Scaffold out a Chrome extension
JavaScript
2,617
star
6

update-notifier

Update notifications for your CLI app
JavaScript
1,762
star
7

generator-generator

Generate a Yeoman generator
JavaScript
1,223
star
8

grunt-usemin

[UNMAINTAINED] Replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views)
JavaScript
1,219
star
9

generator

Rails-inspired generator system that provides scaffolding for your apps
TypeScript
1,204
star
10

yeoman-app

A desktop app that scaffolds projects using Yeoman
JavaScript
988
star
11

generator-webapp_DEPRECATED

Yeoman generator that scaffolds out a front-end web app
JavaScript
974
star
12

generator-polymer

Scaffold out a Polymer project
JavaScript
926
star
13

generator-mobile

Scaffold out a mobile project based on Web Starter Kit
JavaScript
918
star
14

configstore

Easily load and persist config without having to think about where and how
JavaScript
866
star
15

yeoman.io

Yeoman website
CSS
790
star
16

generator-backbone

Scaffold out a Backbone.js project
JavaScript
638
star
17

generator-node

Create a Node.js module
JavaScript
577
star
18

insight

Node.js module to help you understand how your tool is being used by anonymously reporting usage metrics to Google Analytics
JavaScript
557
star
19

bower-requirejs

[DEPRECATED] Automagically wire-up installed Bower components into your RequireJS config
JavaScript
375
star
20

generator-chromeapp

Scaffold out a Chrome app
JavaScript
310
star
21

stringify-object

Stringify an object/array like JSON.stringify just without all the double-quotes
JavaScript
307
star
22

grunt-filerev

[DEPRECATED] File revving
JavaScript
260
star
23

yosay

Tell Yeoman what to say
JavaScript
206
star
24

grunt-bower-requirejs

[DEPRECATED] Grunt task - Automagically wire-up installed Bower components into your RequireJS config
JavaScript
198
star
25

generator-bootstrap

Yeoman generator for Bootstrap
JavaScript
186
star
26

generator-karma

Yeoman generator for Karma
JavaScript
172
star
27

environment

Yeoman runtime environment
JavaScript
127
star
28

generator-jquery

Generate a jQuery plugin
JavaScript
85
star
29

generator-gruntfile

Create a basic Gruntfile with yo.
JavaScript
74
star
30

doctor

Detect potential issues with users system that could prevent Yeoman from working correctly
JavaScript
61
star
31

yeoman-assert

Assert utility from yeoman
JavaScript
53
star
32

yeoman-generator-list

JavaScript
52
star
33

generator-mocha

Yeoman generator for Mocha
JavaScript
41
star
34

generator-gruntplugin

Create a gruntplugin module with yo, including Nodeunit unit tests.
JavaScript
35
star
35

generator-jasmine

Yeoman generator for Jasmine
JavaScript
34
star
36

yeoman-character

The Yeoman character in your CLI. Like wat.
JavaScript
21
star
37

yeoman-welcome

Yeoman welcome message used in generators
JavaScript
19
star
38

media

Yeoman logo and artwork
16
star
39

generator-commonjs

Generate a CommonJS module
JavaScript
16
star
40

insight-dashboard

[DEPRECATED] Insight into Yeoman
CSS
11
star
41

Hackathons

Running a Yeoman hackathon? Start here for ideas, tips, and goals
10
star
42

html-wiring

[DEPRECATED] Set of utilities to update HTML files
JavaScript
10
star
43

cli-list

Parse comma-separated argument lists.
JavaScript
9
star
44

yeoman-remote

Fetch packages and archives from remote resources with cache support
JavaScript
8
star
45

generator-dummytest

JavaScript
3
star
46

generator-dummy

Dummy generator used for unit testing purpose
JavaScript
2
star
47

yeoman-api

TypeScript
1
star