Simple guide to creating and publishing npm modules.

When I was first looking into publishing npm modules I was a bit overwhelmed with where to start, and I had a few misconceptions. I always thought that “I had to write ES5 code” and that “everyone is watching you and laughing at your mistakes”. Turns out it’s really simple, and surprisingly quick to do! This post will be covering creating a React component, but if you want to create a plain old JavaScript module you can follow the exact same exact steps. We will be using Rollup for writing ES6 code, but letting us distribute ES5 code.

The 8 steps to publishing a npm module are:

  1. Creating a distributable module using Rollup
  2. Publishing it to npm
  3. Oh.. I guess that’s it.

Read More

Unit testing React components, 5 basic techniques

This post will go through a few simple techniques that are great to know when you are testing your React components.

What packages will be used, and what do they do.

  • Jest: Jest is a test runner, it will execute our tests and provide some utility for spying and stubbing functions.
  • enzyme: Testing utility for React components to help us assert, manipulate and traverse our components.

If you want to get a project up and running to try these things just use create-react-app and add enzyme to it.

Read More