Testing webpack

Testing webpack cases

Note: The tests/webpack-test is heavily based on webpack/test

Progressively migrate webpack test

Originally, we use this formula to calculate the compatibility passedTestCaseCount / totalTestCount, totalTestCount = passedTestCaseCount + failedTestCount + skippedTestCount , but sometimes it maybe hard to compatible with all webpack test cases for some reasons (e.g. performance, legacy feature that we don't want to support), we need a method to skip these tests that we will not support. Thus, we adjust the original formula to (passedTestCaseCount + willNotSupportTestCount) / totalTestCount.

Currently, we use a test.filter.js under each failed test case directory to skip failed test case, using this method could let us migrate webpack test case progressively without affect the real compatibility (Because this method will not influence the real passedTestCaseCount).

e.g.

// test.filter.js
module.exports = () => {
  return false; // false means this testcase is skipped for now, but maybe we will support in the future, `-1` means this test case we don't want to compatible with, this related to `willNotSupportTest`.
};

When you find that we have passed some failed testcases which is skipped for now, you could change the test.filter.js to

module.exports = () => {
  return true;
};

or delete the test.filter.js

Testing webpack plugins cases

Based on implementation differences and performance considerations, Rspack will integrate some webpack plugins internally. The test suite for the plugins will also be copied to the rspack-plugin-ci for testing plugin compatibility.

Therefore, in order to maintain consistency with the original repository, it is not recommended to modify these test cases, except in the following scenarios:

  • When a new webpack plugin is integrated into Rspack, the test cases for that plugin need to be copied.
  • When there are differences between the artifacts of Rspack and webpack (e.g., different hashes), some test cases may need modification.

In scenarios other than those mentioned above, please follow the Rspack Testing guidelines for adding test cases.