npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jest-webpack

v0.5.1

Published

Use webpack loader and plugins you want to build modules into individual files and test them with jest.

Downloads

6,768

Readme

jest-webpack

Build Status Build status

A helper tool and webpack plugin to integrate jest and webpack.

Add it to your project as a developer dependency. And run it like webpack or webpack-dev-server from the command line or as a package.json script.

Install

npm install --save-dev jest-webpack

or with yarn

yarn add -D jest-webpack

Update package.json

Add it as a package.json script

{
  "name": "my-package",
  "scripts": {
    "test": "jest-webpack"

Run it

npm test

Run it with jest options

npm test -- --testPathPattern test-just-this-file

Status

jest-webpack currently works with a lot of jest options out of the bag since there is no special handling needed and they can just be passed to jest by the tool. You can see what is so far specifically tested so far in https://github.com/mzgoddard/jest-webpack/issues/3.

How it works?

jest-webpack uses a webpack plugin to add related plugins that are responsible for 4 operations.

  1. The TestEntriesPlugin finds test files that jest will operate on and creates entry chunks for them.
  2. The EntryReferencePlugin creates additional entries for any other files that are depended on by those test files. These entries return objects pointing to the various transformations of that file. If a css file is depended on by both css-loader and css-loader/locals for example, both of the outputs of those loaders will be in the same file. Files then depending on those outputs reference the entry chunk and use the exported member for their needed version of the original file.
  3. The EmitChangedAssetsPlugin removes entry chunks that already exist in the destination folder. It also includes package.json for the tested project.
  4. The RunJestWhenDonePlugin runs jest when webpack is done. It runs jest from the destination folder so jest uses the webpack transformed files. This lets jest determine what files changed and which runs to test again instead of testing all the files again.

This way of integrating jest and webpack is fairly transparent, requiring little modification to a webpack project. Used along with source-map-support, you can also get source maps.

Special Thanks

Thanks to Colch for letting me take over development of a jest-webpack integration as the jest-webpack npm package.