Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@simplrjs/test-generator-cli

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@simplrjs/test-generator-cli

Tool to generate tests from cases.

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

test-generator-cli

Tool to generate tests from cases.

Installation

npm install @simplrjs/test-generator-cli -g

Global installation is not necessary. You can install this package with:

npm install @simplrjs/test-generator-cli --save-dev

and use it with npm-scripts.

Command line

Usage

test-generator-cli -h

Arguments

ArgumentTypeDefaultDescription
-h, --helpbooleanfalseShow help.
-v, --versionbooleanfalseShow current version.
-p, --projectstring./Project directory path.

Project tests structure

Let's say you picked src as your project directory.

├── src
    └── tests
        ├── cases
        │   ├── __tests__
        │   |   └── __snapshots__
        │   ├── case-1
        │   │   ├── ...
        │   │   ├── test-config.json
        │   │   └── case.test.tpl
        │   └── case-2
        └── default.test.tpl
File / DirectoryDescription
__tests__Generated tests output directory.
__snapshots__Generated tests snapshots directory.
case-1, case-2Directories for test cases.
case.test.tplTest template file for certain test case. It's not required. If case.test.tpl not found in case directory, test template will fallback to default.test.tpl.
test-config.jsonConfig file for a test case. You can reach it template. Config structure is at your discretion.
default.test.tplDefault test template file.

Templates

Package supports two kinds of templates:

  • case.test.tpl - test template file for certain test case. It's not required. If case.test.tpl not found in case directory, test template will fallback to default.test.tpl.
  • default.test.tpl - default test template file.

Template should be a valid TypeScript file that can have Handlebars expressions.

Supported expressions
ExpressionDescription
{{caseName}}Test case name.
{{projectDirectory}}Project directory path.
{{json testConfig}}Test case config file (test-config.json) content.
Sample
import * as path from "path";
import { Bundler } from "@src/bundler";

test("{{caseName}}", async done => {
    const projectDirectory = "{{projectDirectory}}";
    const testConfig = {{{json testConfig}}};
    const entryFile = path.join(projectDirectory, testConfig.Entry);

    try {
        const bundleResult = await new Bundler()
            .BundleAll([entryFile]);
        expect(bundleResult[0].bundledContent).toMatchSnapshot();
        done();
    } catch (error) {
        done.fail(error);
    }
});

License

Released under the MIT license.

Keywords

FAQs

Package last updated on 15 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc