GithubHelp home page GithubHelp logo

isabella232 / storytests-webpack-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yandex/storytests-webpack-plugin

0.0 0.0 0.0 1.91 MB

Plugin for creating test files according to Storybook

License: MIT License

JavaScript 100.00%

storytests-webpack-plugin's Introduction

Travis

Storytests Webpack Plugin

If you use Storybook and you want to cover all your stories by tests, this plugin helps you to do this.
This plugin creates test files based on your Storybook structure.

Installation

npm i storytests-webpack-plugin --save-dev

Usage

Define parameters

  1. path to stories
    storyFilesPath: string; // e.g. "components/**/__stories__/*.stories.tsx"
  2. pattern for component name in your story files
    componentNamePattern: RegExp; // e.g. /[a-z]+(?=", module)/gi
  3. pattern for story name in your story files
    storyNamePattern: RegExp; // e.g. /[a-z ]+(?=", \(\) => )/gi
  4. path to directory with tests related to story
    testDirectoryPath: string; // e.g." ../../tests"
  5. postfixes for test files
    testFilePostfixes: string[]; // e.g. ['hermione']
  6. function for generating test file
    testTemplate: (componentName: string, storyName: string) => string;

Add the plugin to your webpack config

import StorytestsWebpackPlugin from 'storytests-webpack-plugin';
import { componentNamePattern, storyFilesPath, storyNamePattern, testDirectoryPath, testFilePostfixes } from './constants/';
import { testTemplate } from './helpers/';
...
module.exports = {
    ...
    plugins: [
        new StorytestsWebpackPlugin({
            componentNamePattern,
            storyFilesPath,
            storyNamePattern,
            testDirectoryPath,
            testFilePostfixes,
            testTemplate
        })
    ]
}

For contributors

Required Node.js version: 12.18.0
Required npm version: 6.14.4
How to install: https://nodejs.org/en/download/

How to publish

  1. Update package version in package.json and package-lock.json

  2. Run:

npm run build
npm publish

storytests-webpack-plugin's People

Contributors

baushonok avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.