webpack/test
Jordan West 552d05e268 lint fix 2018-05-07 11:54:36 +10:00
..
benchmarkCases fixed linting 2017-03-31 16:00:00 +02:00
binCases fix mixture of tabs and spaces 2017-12-28 04:19:44 -06:00
browsertest fix browsertests 2017-05-25 13:12:34 +02:00
cases fix(ConcatenatedModule): don't throw on arrays with empty values 2018-01-29 15:52:01 +01:00
configCases support functions for templated string config properties 2017-12-22 07:28:16 -08:00
fixtures chore: remove temp files 2017-05-29 13:49:35 -05:00
helpers separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
hotCases hot.accept parser stops traversing based on number of args 2018-04-19 10:00:07 -07:00
hotPlayground code linting 2017-01-11 12:29:01 +01:00
statsCases Merge pull request #6242 from nename0/6239-require-ensure-initial-chunks 2018-01-04 21:43:11 +01:00
watchCases Add Tests checking chunkhash of runtime chunk only changes if needed 2018-01-12 23:50:47 +01:00
AmdMainTemplatePlugin.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
BenchmarkTestCases.benchmark.js changing async to asyncLib 2017-04-05 21:06:23 +08:00
BinTestCases.test.js more time for the watch tests 2017-10-19 18:06:36 +02:00
CachePlugin.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
CaseSensitiveModulesWarning.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
Chunk.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
Compilation.test.js lint fix 2018-05-07 11:54:36 +10:00
Compiler-caching.test.js optimize OccurenceOrderPlugin 2017-06-02 01:24:55 +02:00
Compiler.test.js Improvement: Ensure util.depracation use for deprecation warnings 2017-11-20 12:02:10 +02:00
ConfigTestCases.test.js prevent crashing when error out early in bail mode 2017-10-11 15:28:18 +02:00
ContextDependencyTemplateAsId.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
ContextModuleFactory.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
ContextReplacementPlugin.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
DelegatedModule.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
DependenciesBlockVariable.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
Errors.test.js Improvement: Ensure util.depracation use for deprecation warnings: revert NoErrors plugin 2017-11-20 13:55:21 +02:00
Examples.test.js Refactor example scripts and test to allow nested folders 2017-07-27 13:24:56 +02:00
ExternalModule.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
HarmonyExportImportedSpecifierDependency.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
HarmonyModulesHelpers.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
HotModuleReplacementPlugin.test.js refactor(ES6): HotModuleReplacementPlugin.test.js 2017-01-18 16:08:06 +05:30
HotTestCases.test.js Disallow Scope Hoisting when using HMR 2017-08-12 11:00:55 +02:00
HotUpdateChunkTemplate.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
Integration.test.js refactor(ES6): Integration.test.js 2017-01-18 16:23:19 +05:30
JsonpExportMainTemplatePlugin.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
JsonpHotUpdateChunkTemplatePlugin.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
LibraryTemplatePlugin.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
LocalModulesHelpers.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
ModuleDependencyError.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
ModuleReason.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
MultiCompiler.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
MultiStats.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
MultiWatching.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
NodeHotUpdateChunkTemplatePlugin.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
NodeTemplatePlugin.test.js Refactor: ES6 lib/node/NodeMainTemplatePlugin.js #4099 2017-06-19 17:35:05 +09:00
NodeWatchFileSystem.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
NormalModule.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
NullDependency.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
Parser.unittest.js Evaluate bitwise and exponential operations 2017-12-05 17:16:45 +01:00
README.md fix filename reference for StatsTestCases.test.js 2017-12-27 23:01:06 -06:00
RawModule.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
RecordIdsPlugin.test.js unify makeRelative method used in aggresivesplittingplugin and recordsidsplugin 2017-04-05 23:38:15 +10:00
RequireJsStuffPlugin.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
RuleSet.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
Schemas.lint.js fix an issue with schemas in subdirectories 2017-11-18 21:03:45 +01:00
SortableSet.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
SourceMapDevToolModuleOptionsPlugin.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
Stats.unittest.js add tests for hasErrors and hasWarnings with children taken into account 2017-12-22 00:18:47 -06:00
StatsTestCases.test.js update NoEmitOnErrorsPlugin to recognize child compilation errors, add tests 2017-12-28 03:41:42 -06:00
Template.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
TestCases.test.js fix($chore): put back TestCases.test.js to original 2017-07-26 13:12:59 +02:00
UmdMainTemplatePlugin.unittest.js Rename UmdMainTemplatePlugin.test.js to UmdMainTemplatePlugin.unittest.js 2017-10-19 19:46:20 +02:00
Validation.test.js support functions for templated string config properties 2017-12-22 07:28:16 -08:00
WatchDetection.test.js close watchers correctly when closing watching 2017-03-15 15:50:05 +01:00
WatchTestCases.test.js Add Tests checking chunkhash of runtime chunk only changes if needed 2018-01-12 23:50:47 +01:00
WatcherEvents.test.js add timeout and code style 2017-05-29 10:52:30 +02:00
WebEnvironmentPlugin.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
WebWorkerChunkTemplatePlugin.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
WebWorkerHotUpdateChunkTemplatePlugin.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
WebWorkerMainTemplatePlugin.unittest.js fixup! [fix] error on HMR with es6 bundles 2017-10-30 08:43:56 +01:00
WebpackError.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
WebpackMissingModule.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
checkArrayExpectation.js Refactor CheckArrayExpectation to ES6 2017-04-06 16:17:43 +08:00
compareLocations.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
formatLocation.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
identifier.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00
lint-mocha.opts add linting for schemas 2017-11-16 13:15:15 +01:00
mocha.opts Revert "chore(test): skip failure for global var in macaddress" 2017-01-18 13:23:40 +01:00
removeAndDo.unittest.js separate integration and unit tests, use codecov flags 2017-10-19 17:35:20 +02:00

README.md

Welcome to the webpack test suite!!!!

Every pull request that you submit to webpack (besides README and spelling corrections in comments) requires tests that are created.

But don't give up hope!!! Although our tests may appear complex and overwhelming, once you become familiar with the test suite and structure, adding and creating tests will be fun and beneficial as you work inside the codebase! ❤

tl;dr

  • Clone repo

  • install and link deps

    • yarn install && yarn link && yarn link webpack
    • yarn test
  • To run an individual suite: (recommended during development for easier isolated diffs)

Example: $(npm bin)/mocha --grep ConfigTestCases

Test suite overview

We use MochaJS for our tests. For more information on Mocha you can visit their homepage!

Class Tests

All test files can be found in *.test.js. There are many tests that simply test API's of a specific class/file (such as Compiler, Errors, Integration, Parser, RuleSet, Validation). If the feature you are contributing involves one of those classes, then best to start there to understand the structure.

xCases

In addition to Class specific tests, there are also directories that end in "Cases". The suites for these cases also have corresponding *.test.js files.

cases (TestCases.test.js) 1

Cases are a set of general purpose tests that will run against a variety of permutations of webpack configurations. When you are making a general purpose change that doesn't require you to have a special configuration, you would likely add your tests here. Inside of the ./test/cases directory you will find tests are broken into thematic sub directories. Take a moment to explore the different options.

To add a new case, create a new directory inside of the top level test groups, and then add an index.js file (and any other supporting files).

By default this file will be the entry point for the test suite and you can add your it()'s there. This will also become bundled so that node env support happens as well.

configCases (ConfigTestCases.test.js) 1

If you are trying to solve a bug which is reproducible when x and y properties are used together in a config, then configCases is the place to be!!!!

In addition to an index.js, these configCases require a webpack.config.js is located inside of your test suite. This will run this specific config through webpack just as you were building individually. They will use the same loading/bundling technique of your it() tests, however you now have a more specific config use cases that you can write even before you start coding.

statsCases (StatsTestCases.test.js)

Stats cases are similar to configCases except specifically focusing on the expected output of your stats. Instead of writing to the console, however the output of stats will be written to disk.

By default, the "expected" outcome is a pain to write by hand so instead when statsCases are run the following happens:

  • Checks for expected.txt file containing expected results.
  • If the expected.txt doesn't match what is output, then an actual.txt stats output file will be created and the test will fail. (A typical workflow for stats cases is to fail the test and copy the results from actual.txt to expected.txt.)
  • If the actual output matches expected.txt, the tests passes and you are free to submit that PR with pride!!!

Questions? Comments?

If you are still nervous or don't quite understand, please submit an issue and tag us in it, and provide a relevant PR while working on!

Footnotes

1 webpack's parser supports the use of ES2015 features like arrow functions, harmony exports, etc. However as a library we follow NodeJS's timeline for dropping older versions of node. Because of this we expect your tests on Travis to pass all the way back to NodeJS v0.12; Therefore if you would like specific tests that use these features to be ignored if they are not supported, then you should add a test.filter.js file. This allows you to import the syntax needed for that test, meanwhile ignoring it on node versions (during CI) that don't support it. webpack has a variety of helpful examples you can refer to if you are just starting out. See the ./helpers folder to find a list of the versions.