|
3 | 3 | ## Optimize Planning Step |
4 | 4 |
|
5 | 5 | When using ddtest, you need to add a planning step that performs test discovery |
6 | | -(for example, RSpec dry-run, pytest collection, or Jest `--listTests`) before |
7 | | -execution. This stage adds overhead: you can optimize it with the practices |
8 | | -below. |
| 6 | +before execution. For Ruby and Python, this can involve full framework |
| 7 | +discovery such as RSpec dry-run or pytest collection. For Jest, DDTest uses |
| 8 | +Jest's `--listTests` command to discover test files. This planning stage adds |
| 9 | +overhead: you can optimize it with the practices below. |
9 | 10 |
|
10 | 11 | ### Preinstall System Dependencies Via Docker |
11 | 12 |
|
@@ -50,6 +51,15 @@ For GitHub Actions + npm: |
50 | 51 | cache: npm |
51 | 52 | ``` |
52 | 53 |
|
| 54 | +For GitHub Actions + npm: |
| 55 | +
|
| 56 | +```yaml |
| 57 | +- uses: actions/setup-node@v4 |
| 58 | + with: |
| 59 | + node-version: "22" |
| 60 | + cache: npm |
| 61 | +``` |
| 62 | +
|
53 | 63 | ### Disable Seeds/Fixtures During Discovery |
54 | 64 |
|
55 | 65 | Discovery (planning) does not execute tests; you don't have to setup DB, |
@@ -135,6 +145,8 @@ the cache when files under the current project's test root changed. For example, |
135 | 145 | the default RSpec root is `spec/**`, the default Minitest root is `test/**`, |
136 | 146 | pytest uses `testpaths` from pytest config when available, and Jest uses the |
137 | 147 | project's Jest test matching unless `--tests-location` is set. With |
| 148 | +pytest uses `testpaths` from pytest config when available, and Jest uses the |
| 149 | +project's Jest test matching unless `--tests-location` is set. With |
138 | 150 | `--tests-location custom/spec/**/*_spec.rb`, the root is `custom/**`. |
139 | 151 |
|
140 | 152 | In monorepos, run DDTest from the project subdirectory whose tests you are |
@@ -175,6 +187,29 @@ where DDTest runs. |
175 | 187 | Jest support uses suite-level Test Impact Analysis. DDTest discovers and splits |
176 | 188 | test files/suites, not individual Jest tests. |
177 | 189 |
|
| 190 | +## Jest Support |
| 191 | + |
| 192 | +DDTest runs Jest through the local `node_modules/.bin/jest` executable when it |
| 193 | +exists, or through `npx jest` otherwise. During planning it appends |
| 194 | +`--listTests`; during execution it appends `--runTestsByPath` and the selected |
| 195 | +test files. |
| 196 | + |
| 197 | +Use `--command` when your project runs Jest through a package manager or wrapper: |
| 198 | + |
| 199 | +```bash |
| 200 | +ddtest run --platform javascript --framework jest --command "pnpm jest --runInBand" |
| 201 | +``` |
| 202 | + |
| 203 | +Do not include test files or a `--` separator in the command; DDTest appends the |
| 204 | +file list and Jest flags itself. |
| 205 | + |
| 206 | +DDTest prepends `-r dd-trace/ci/init` to `NODE_OPTIONS` for worker processes |
| 207 | +unless it is already present, so `dd-trace` must be resolvable from the project |
| 208 | +where DDTest runs. |
| 209 | + |
| 210 | +Jest support uses suite-level Test Impact Analysis. DDTest discovers and splits |
| 211 | +test files/suites, not individual Jest tests. |
| 212 | + |
178 | 213 | ## Minitest Support In Non-Rails Projects |
179 | 214 |
|
180 | 215 | We use `bundle exec rake test` command when we don't detect `rails` command to |
|
0 commit comments