Skip to content

feats/react-stubs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React-stubs Build Status

Setup

Configure webpack

It will force your *.stub.jsx? files to overlap the non stub files in a given Webpack config file.

const webpack = require('webpack');

module.exports = function(storybookBaseConfig, configType) {
  const jsExtensions = /(\.jsx?)$/;

  storybookBaseConfig.plugins.unshift(
    new webpack.NormalModuleReplacementPlugin(jsExtensions, function(hit) {
      if (!hit.userRequest) {
        return;
      }

      const stub = hit.userRequest.replace(jsExtensions, '.stub$1');

      try {
        require.resolve(stub);

        hit.request = hit.request.replace(hit.userRequest, stub);
        hit.resource = hit.resource.replace(hit.userRequest, stub);
        hit.userRequest = stub;
      } catch(error) {
        if (error.code !== 'MODULE_NOT_FOUND') {
          throw error;
        }
      }
    })
  );

API

composeStub (react-komposer helper)

The simplest most straightforward composer ever.

Usage

import composeStub from 'react-stubs';
import { Address } from './factories';

export default composeStub(({ person }) => ({
  person,
  address: Address.build(),
}));

Motivate

If you like this project just give it a star :) I like stars.

About

Helper methods for stubbing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published