Skip to content

Commit ef09b68

Browse files
docs: more details about testing (#3856)
<!-- Thank you for contributing! --> ### Description <!-- Please insert your description here and provide especially info about the "what" this PR is solving -->
1 parent e0cd410 commit ef09b68

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/contrib-guide/testing.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ run `just test-update` to run all tests and update snapshots automatically
66

77
We have two groups of test suites: one for Rust, and one for Node.js.
88

9+
:::warning Test principle you should respect
10+
11+
1. When adding new feature with options, always make sure adding related tests in javascript side if possible.
12+
13+
Some test related skills maybe helpful [details](#test-skills)
14+
:::
15+
916
## Summary
1017

1118
- `just test` for running all tests.
@@ -109,3 +116,24 @@ In `/packages/rollup-tests`:
109116

110117
- `just test-node rollup` will run rollup tests.
111118
- `just test-node rollup --update` will run and update the tests' status.
119+
120+
### Test skills
121+
122+
Our rust test infra is powerful enough to cover most of the case of javascript(plugin, passing function inside config).
123+
But since Javascript side user is still our first class user, try to put tests in javascript side if possible.
124+
Here are some experience about what test technique you should use.
125+
:::tip TLDR
126+
Add test in javascript side if you don't want to wasting time on deciding which way to use.
127+
:::
128+
129+
#### Prefer Rust
130+
131+
1. Test warning or error emitted by rolldown core.
132+
- [error](https://github.com/rolldown/rolldown/blob/568197a06444809bf44642d88509313ee2735594/crates/rolldown/tests/rolldown/errors/assign_to_import/artifacts.snap?plain=1#L2-L54)
133+
- [warning](https://github.com/rolldown/rolldown/blob/568197a06444809bf44642d88509313ee2735594/crates/rolldown/tests/rolldown/warnings/eval/artifacts.snap?plain=1#L1-L28)
134+
2. Matrix testing, assume you want to test a suite different [format](https://github.com/rolldown/rolldown/blob/568197a06444809bf44642d88509313ee2735594/crates/rolldown/tests/rolldown/topics/bundler_esm_cjs_tests/4/_config.json?plain=1#L1-L21), with `configVariants` you could do that with only one test.
135+
3. Tests related to linking algorithm(tree shaking, chunk splitting) Those may require a lot of debugging, add test on rust side could reduce the time of coding-debug-coding work loop.
136+
137+
#### Prefer Javascript
138+
139+
Any category not mentioned above should put in javascript side.

0 commit comments

Comments
 (0)