1.2.15 • Published 6 years ago

platelunch v1.2.15

Weekly downloads
21
License
MIT
Repository
github
Last release
6 years ago

Platelunch

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.

1.2.15

6 years ago

1.2.14

6 years ago

1.2.13

6 years ago

1.2.12

6 years ago

1.2.11

6 years ago

1.2.10

6 years ago

1.2.9

6 years ago

1.2.8

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago