New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

platelunch

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

platelunch

Generate boilerplate code for unit tests

  • 1.2.15
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by20%
Maintainers
1
Weekly downloads
 
Created
Source

Platelunch

Travis Codecov npm version code style: platelunch semantic-release greenkeeper

Platelunch logo

Intro

Platelunch generates boilerplate unit test code for javascript source files. Currently it will generate unit test files to be used with jest only. More testing frameworks will be supported.

Install

npm install --save-dev platelunch

--- or globally

npm install -g platelunch

CLI

platelunch [opts] [filename ...]

Platelunch will create a directory __tests__ where all the generated unit test files will be created.

WARNING If a test file exists in __tests__ it will be overwritten unless the glob or filename does not include that file.

Using glob to find files to generate unit tests

platelunch --test-framework jest "src/**/*.js"

Only one unit test file will be generated

platelunch --test-framework jest "src/my-file.js"

Examples

module.exports

Source File
function add(num1, num2) {
  return num1 + num2;
}

module.exports = {
  add: add
};
Generated unit test file
const add = require("src/my-module.js").add;

describe("my-module.js", () => {
  test("add", () => {
    const num1 = null;
    const num2 = null;
    
    const result = add(num1, num2);
  });
});

exports

Source File
function add(num1, num2) {
  return num1 + num2;
}

export { add };
Generated unit test file
import { add } from "src/my-module.js"

describe("my-module.js", () => {
  test("add", () => {
    const num1 = null;
    const num2 = null;
    
    const result = add(num1, num2);
  });
});

class (ES2015)

Source File
export class TestClass {
  add(num1, num2) {
    return num1 + num2;
  }
};
Generated unit test file
import { TestClass } from "TestClass.js";

describe("TestClass.js", () => {
  let testClass;

  beforeEach(() => {
    testClass = new TestClass();
  });

  test("add", () => {
    const num1 = null;
    const num2 = null;
    const result = testClass.add(num1, num2);
  });
});

Licensing

The code in this project is licensed under MIT license.

Keywords

FAQs

Package last updated on 11 Jul 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