Testing the webpack codebase

Pavithra Kodmad
Webpack Nuggets
Published in
2 min readJul 7, 2017

This article will teach you how to setup the webpack codebase to run it’s test suites.

  • Get an understanding of how to run tests on the webpack codebase
  • Make the barrier to entry of contributing to webpack that much lower.

Clone and run webpack

git clone https://github.com/webpack/webpack.git
cd webpack
npm install

Link webpack to point to the local instance

To understand npm link , please read this excellent article.

npm link // At the root of webpack folder
npm link webpack

Run the tests

npm run test

If you check out webpack's package.json, we see the following scripts

test:"mocha test/*test.js"
pretest:npm run lint-files

First, the pretest script is run. This makes sure all the code conforms to the linting rules. Next it runs the mocha script to run all files ending with .test.js

You will see a bunch of dots appear on the screen. This is a special Mocha test-reporter called dot which compresses passing test cases to a single dot. If you want to see more details you can edit the file mocha.opts file to change the reporter to list or any of the other reporter options you may be comfortable with.

Now that you have seen the tests run, delve deeper into it at the webpack/test folder and read the excellent README.md

--

--