mirror of https://github.com/webpack/webpack.git
docs: added TESTING_DOCS for better understanding of testing (#19249)
This commit is contained in:
parent
fdfb92ae3e
commit
4fde180e9a
|
@ -47,6 +47,7 @@ Something that will increase the chance that your pull request is accepted:
|
||||||
- For a major fix/feature make sure your PR has an issue and if it doesn't, please create one. This would help discussion with the community, and polishing ideas in case of a new feature.
|
- For a major fix/feature make sure your PR has an issue and if it doesn't, please create one. This would help discussion with the community, and polishing ideas in case of a new feature.
|
||||||
- Make sure your PR's description contains GitHub's special keyword references that automatically close the related issue when the PR is merged. ([More info](https://github.com/blog/1506-closing-issues-via-pull-requests))
|
- Make sure your PR's description contains GitHub's special keyword references that automatically close the related issue when the PR is merged. ([More info](https://github.com/blog/1506-closing-issues-via-pull-requests))
|
||||||
- When you have a lot of commits in your PR, it's good practice to squash all your commits in one single commit. ([Learn how to squash here](https://davidwalsh.name/squash-commits-git))
|
- When you have a lot of commits in your PR, it's good practice to squash all your commits in one single commit. ([Learn how to squash here](https://davidwalsh.name/squash-commits-git))
|
||||||
|
- For a better understanding of the folder structure and testing procedures, refer to the [Testing Documentation](./TESTING_DOCS.md).
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,102 @@
|
||||||
|
# Webpack Test Suite Structure
|
||||||
|
|
||||||
|
This document explains the structure of the `test/` directory in the Webpack project using Jest. The directory is organized into multiple folders and files, each serving a specific purpose in testing various aspects of Webpack’s functionality.
|
||||||
|
|
||||||
|
## Folder and File Breakdown
|
||||||
|
|
||||||
|
### 1. `__snapshots__/`
|
||||||
|
|
||||||
|
- **Purpose**: Stores Jest snapshot files for comparing output consistency over time.
|
||||||
|
- **Usage**: Used for testing UI components, serialized data, or expected module outputs.
|
||||||
|
|
||||||
|
### 2. `benchmarkCases/`
|
||||||
|
|
||||||
|
- **Purpose**: Contains test cases for benchmarking Webpack's performance.
|
||||||
|
- **Usage**: Measures build times, memory usage, and optimization impact.
|
||||||
|
|
||||||
|
### 3. `cases/`
|
||||||
|
|
||||||
|
- **Purpose**: General test cases covering core functionalities.
|
||||||
|
- **Usage**: Includes unit and integration tests for various modules and features.
|
||||||
|
|
||||||
|
### 4. `configCases/`
|
||||||
|
|
||||||
|
- **Purpose**: Tests related to Webpack configurations.
|
||||||
|
- **Usage**: Ensures that Webpack’s configuration (e.g., loaders, plugins) functions correctly.
|
||||||
|
|
||||||
|
### 5. `fixtures/`
|
||||||
|
|
||||||
|
- **Purpose**: Stores sample/mock data used in tests.
|
||||||
|
- **Usage**: Helps in creating consistent test cases with predefined inputs.
|
||||||
|
|
||||||
|
### 6. `helpers/`
|
||||||
|
|
||||||
|
- **Purpose**: Utility functions and scripts to assist in testing.
|
||||||
|
- **Usage**: Provides reusable functions for mock data generation, cleanup, and assertions.
|
||||||
|
|
||||||
|
### 7. `hotCases/`
|
||||||
|
|
||||||
|
- **Purpose**: Focuses on Webpack’s Hot Module Replacement (HMR) functionality.
|
||||||
|
- **Usage**: Ensures live reloading and hot updates work correctly.
|
||||||
|
|
||||||
|
### 8. `hotPlayground/`
|
||||||
|
|
||||||
|
- **Purpose**: An experimental space for testing HMR features.
|
||||||
|
- **Usage**: Allows exploration of new HMR implementations.
|
||||||
|
|
||||||
|
### 9. `memoryLimitCases/json`
|
||||||
|
|
||||||
|
- **Purpose**: Contains test cases related to memory limits.
|
||||||
|
- **Usage**: Ensures Webpack doesn’t exceed memory constraints.
|
||||||
|
|
||||||
|
### 10. `statsCases/`
|
||||||
|
|
||||||
|
- **Purpose**: Tests focused on Webpack’s statistical outputs.
|
||||||
|
- **Usage**: Verifies correct bundle sizes, dependencies, and optimizations.
|
||||||
|
|
||||||
|
### 11. `typesCases/`
|
||||||
|
|
||||||
|
- **Purpose**: Type-checking tests, likely for TypeScript integration.
|
||||||
|
- **Usage**: Ensures proper type definitions and compliance.
|
||||||
|
|
||||||
|
### 12. `watchCases/`
|
||||||
|
|
||||||
|
- **Purpose**: Tests for Webpack’s watch mode functionality.
|
||||||
|
- **Usage**: Ensures file changes trigger correct rebuild behavior.
|
||||||
|
|
||||||
|
### 13. `*.unittest.js`
|
||||||
|
|
||||||
|
- **Purpose**: Contains unit tests for various functionalities.
|
||||||
|
- **Usage**: Ensures individual modules and functions work as expected.
|
||||||
|
|
||||||
|
### 14. `BannerPlugin.test.js`
|
||||||
|
|
||||||
|
- **Purpose**: Tests Webpack’s `BannerPlugin` functionality.
|
||||||
|
- **Usage**: Ensures that the plugin correctly adds banners to the bundled files.
|
||||||
|
|
||||||
|
## Testing Framework
|
||||||
|
|
||||||
|
- **Jest** is used for running tests.
|
||||||
|
- Snapshots help maintain consistency in output.
|
||||||
|
- Unit tests verify individual module functionality.
|
||||||
|
- Integration tests ensure multiple components work together.
|
||||||
|
|
||||||
|
## How to Run Tests
|
||||||
|
|
||||||
|
To execute all tests, use the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
yarn test
|
||||||
|
```
|
||||||
|
|
||||||
|
For running specific tests:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
jest cases/userLogic.test.js
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contribution Guide
|
||||||
|
|
||||||
|
- Add new test cases in the appropriate folder.
|
||||||
|
- Use Jest assertions and mocks for consistency.
|
||||||
|
- Run `yarn test` before pushing changes to validate functionality.
|
Loading…
Reference in New Issue