Effortless Test Case Generation.

TestWeaver is a command-line tool that generates comprehensive test cases from simple YAML test plans.

Stop Writing Boilerplate. Start Writing Code.

As developers, we spend too much time on repetitive, mechanical tasks. Generating test files for new features, modules, or bug fixes is one of them. TestWeaver automates this process, allowing you to quickly scaffold your test architecture and focus on what really matters: writing the test logic itself. With simple YAML, you can define your test cases in a clean, human-readable format, leaving the tedious file creation to the CLI.

Features

Fast Test Generation

Quickly generate boilerplate test files and code from a simple YAML test plan.

Language Agnostic

Works with any programming language, including JavaScript and TypeScript, by using custom templates for your test files.

Flexible Test Plans

Define test suites, units, and custom variables with a simple YAML file.

How to Use TestWeaver

1. Install the CLI

Install TestWeaver globally via npm.

npm install -g test-weaver

2. Create Your YAML Test Plan

Define your test suites and properties in a `your-file.yml`.

User Authentication:
  Logging in:
    With correct credentials:
      - should return a valid JWT
      - should set a session cookie
    With incorrect credentials:
      - should return a 401 error
      - should not return a JWT
  Registering a new user:
    With valid data:
      - should create a new user record
      - should return a 201 status code
    With invalid data:
      - should return a 400 error
      - should not create a new user

3. Run the Generator

Execute the `generate` command with your YAML test plan.

testweaver generate your-file.yml

YAML vs. Generated Test File

YAML Test Plan (`your-file.yml`)

User Authentication:
  Logging in:
    With correct credentials:
      - should return a valid JWT
      - should set a session cookie
    With incorrect credentials:
      - should return a 401 error
      - should not return a JWT
  Registering a new user:
    With valid data:
      - should create a new user record
      - should return a 201 status code
    With invalid data:
      - should return a 400 error
      - should not create a new user

Generated Test File (`your-file.test.js`)

describe('User Authentication', () => {
  describe('Logging in', () => {
    describe('With correct credentials', () => {
      it.todo('should return a valid JWT');
      it.todo('should set a session cookie');
    });

    describe('With incorrect credentials', () => {
      it.todo('should return a 401 error');
      it.todo('should not return a JWT');
    });
  });

  describe('Registering a new user', () => {
    describe('With valid data', () => {
      it.todo('should create a new user record');
      it.todo('should return a 201 status code');
    });

    describe('With invalid data', () => {
      it.todo('should return a 400 error');
      it.todo('should not create a new user');
    });
  });
});

Real-time Updates with Watch Mode

Use the `--watch` option to have TestWeaver automatically update your test files every time you save a change in your YAML test plan. This feature is perfect for building out your test suite incrementally.

Command to run:

testweaver generate **/*.yaml --watch 
An animated GIF showing TestWeaver automatically updating a test file based on changes to a YAML test plan.

Frequently Asked Questions

What is TestWeaver?

TestWeaver is a command-line interface (CLI) tool designed to automate the generation of test case files from simple YAML test plans, helping developers save time and reduce boilerplate code.

How do I install TestWeaver?

You can install TestWeaver globally using npm with the following command: npm install -g test-weaver

What is the main benefit of using TestWeaver?

The primary benefit is efficiency. TestWeaver automates the creation of test file structures, allowing developers to focus on writing the actual test logic instead of spending time on repetitive setup and boilerplate.

What kind of file does TestWeaver use to generate tests?

TestWeaver uses a simple and human-readable YAML test plan (`.yml`) to define test suites, units, and their descriptions.

How do I generate a test file?

After creating your YAML test plan (e.g., `your-file.yml`), you can generate the corresponding test file by running the command: testweaver generate your-file.yml

What does the generated test file look like?

The generated file will be a test file (e.g., `your-file.test.js`) that mirrors the structure of your YAML test plan, with `describe` blocks for your test suites and `it.todo()` placeholders for your individual test cases.

What is "Watch Mode"?

Watch Mode is a feature that automatically regenerates your test files whenever you save a change to your YAML test plan. This is ideal for incrementally building out your test suite without manually running the `generate` command each time.

How do I use Watch Mode?

You can activate Watch Mode by adding the `--watch` flag to the `generate` command, like this: testweaver generate **/*.yaml --watch

Is TestWeaver an open-source project?

Yes, the "View on GitHub" button on the website indicates that TestWeaver is an open-source project, and its source code is available on GitHub.

What problem does TestWeaver solve?

TestWeaver addresses the common developer pain point of writing repetitive, boilerplate code for test files. It streamlines the initial phase of testing by scaffolding the entire test structure from a simple YAML test plan.

What are the key features of TestWeaver?

The main features are:

  • **Fast Test Generation:** Quickly create test files from a YAML test plan.
  • **Flexible Test Plans:** Define test suites and units with a simple YAML structure.
  • **Watch Mode:** Automatically update test files on save.

How does the YAML test plan translate to a test file?

The nested structure of the YAML file directly maps to nested `describe` blocks in the generated test file. The final test case descriptions in the YAML become `it.todo()` statements.

Where can I see a demonstration of TestWeaver in action?

The "Watch Mode" section of the website features an animated GIF that shows TestWeaver automatically updating a test file based on changes to a YAML test plan.

Who is the target audience for TestWeaver?

TestWeaver is for any developer who writes unit or integration tests and wants to speed up their workflow by automating the creation of test file boilerplate.