Numerous Pulsating Martians

    yeoman-test
    DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/yeoman-test package

    6.2.0 • Public • Published

    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:

    describe('generator test', () => {
      describe('test', () => {
        let runResult;
        beforeEach(async () => {
          runResult = await helpers
            .create(                   // instantiates RunContext
              'namespace',             // namespace or generator
              {},                      // test options
              {}                       // environment options
            )
            [.cd(dir)]                  // runs the test inside a non temporary dir
            [.doInDir(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
            [.withPrompts()]            // simulates the prompt answers
            [.build(runContext => {     // instantiates Environment/Generator
              [runContext.env...]       // does something with the environment
              [runContext.generator...] // does something with the generator
            })]
            .run();                     // runs the environment, promises a RunResult
          [result.create().run()] // instantiates a new RunContext at the same directory
        );
        afterEach(() => {
          if (runResult) {
            runResult.restore();
          }
        });
        it('runs correctly', () => {
          // runs assertions using mem-fs.
          [runResult.assertFile('file.txt');]
          [runResult.assertNoFile('file.txt');]
          [runResult.assertFileContent('file.txt', 'content');]
          [runResult.assertEqualsFileContent('file.txt', 'content');]
          [runResult.assertNoFileContent('file.txt', 'content');]
          [runResult.assertJsonFileContent('file.txt', {});]
          [runResult.assertNoJsonFileContent('file.txt', {});]
        });
      });
    });

    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

    Install

    npm i yeoman-test

    DownloadsWeekly Downloads

    32,470

    Version

    6.2.0

    License

    MIT

    Unpacked Size

    43.3 kB

    Total Files

    7

    Last publish

    Collaborators

    • sboudrias
    • mshima
    • ruyadorno
    • eddiemonge
    • mischah
    • arthurvr