webpack-contrib / organization

Applications, Standards & Documentation for webpack-contrib.
14 stars 10 forks source link

[WIP] Jest testing implementation #9

Closed joshwiens closed 7 years ago

joshwiens commented 7 years ago

Background

Jest was chosen as the tool for the contrib organization and rightly so imo. It's fast, snapshots are the hotness & the development experience is so far beyond any other offering it's almost embarrassing.

Both webpack & webpack-contrib have some interesting testing scenarios / requirements that make the conversion challenging while retaining all of Jest's features. The biggest ticket item within webpack-contrib is retaining Jest's incremental / async functionality while unit testing loaders & plugins through webpack without a pretest build step.

Fortunately, Jest has a solution for such problems, the mighty Preprocessor. Unfortunately, that is not as simple as it sounds or at lest it wasn't last I researched this issue a few months ago.

Requirements

Short Term Goals

Within the scope of webpack-contrib our highest priority is to get the webpack-defaults upgrades complete. A part of those upgrades is either a conversion of existing unit tests or their addition where none exist.

Given additional tooling to some extent will likely need to be developed to meet all the requirements listed above, the initial defaults pass should not execute unit tests through webpack with a pretest compile step. The simple fact is, refactors are few and far between & features land far more often. The initial pass of defaults should leverage Jest in all it's glory without compromise & a preprocessor can be added later to handle the through webpack portion as a feature in webpack-defaults.

The obvious risk there is the occasional got ya where a unit test passes but the functionality is broken in the context of webpack. Given the infrequency of that occurring, imo the level of risk is acceptable when weighed against the benefits of a no compromise implementation of Jest.

A good benchmark for test setups in the short term is https://github.com/webpack-contrib/css-loader/tree/new-loader/test

End Game

Currently very wip ...