TE-6261 - Add a vitest runner#580
Conversation
Much of the logic can be re-used from the Jest runner, with the addition of `skipped` tests, which Jest incorrect reports as `pending`.
There was a problem hiding this comment.
I found one blocker in the Vitest retry path: top-level test failures can be converted into skipped results on retry.
Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:
Download the buildsworth logs from build 2493, then answer my questions about the findings.
Co-authored-by: buildsworth-bk-app[bot] <265670805+buildsworth-bk-app[bot]@users.noreply.github.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Previous concerns have been addressed.
There was a problem hiding this comment.
Previous blocker is resolved: the Vitest retry pattern now builds top-level test names without the leading separator. I didn’t find new code issues; leaving this as a comment rather than approval because this is a new runner integration (L2) and I don’t see an L2 approval grant.
Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:
Download the buildsworth logs from build 2497, then answer my questions about the findings.
There was a problem hiding this comment.
Previous blocker is resolved: the Vitest retry pattern now builds top-level test names without the leading separator. I didn’t find new high-confidence code issues; leaving this as a comment rather than approval because this is a new runner integration (L2) and I don’t see an L2 approval grant.
Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:
Download the buildsworth logs from build 2499, then answer my questions about the findings.
nprizal
left a comment
There was a problem hiding this comment.
Looks good to me. Can we update the default test command to include both default and json reporter?
Co-authored-by: Naufan P. Rizal <np.rizal@icloud.com>
Co-authored-by: Naufan P. Rizal <np.rizal@icloud.com>
Co-authored-by: Naufan P. Rizal <np.rizal@icloud.com>
Co-authored-by: Naufan P. Rizal <np.rizal@icloud.com>
|
Thanks @nprizal! Applied the suggestions |
There was a problem hiding this comment.
I found one blocker in the follow-up: the Vitest default command now includes the default reporter, but the new unit test expectations still assert the previous command. The CI check is currently blocked/pending, so this is from the diff rather than a completed build.
Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:
Download the buildsworth logs from build 2541, then answer my questions about the findings.
| { | ||
| input: RunnerConfig{}, | ||
| want: RunnerConfig{ | ||
| TestCommand: "npx vitest run {{testExamples}} --reporter=json --outputFile {{resultPath}}", |
There was a problem hiding this comment.
Blocking: NewVitest now sets the default command to include both --reporter=default and --reporter=json, but this expected value still only has the JSON reporter. The retry expectation on line 25 has the same mismatch, so TestNewVitest will fail until these defaults are updated to match the implementation.
| By default, bktec runs Vitest with the following command: | ||
|
|
||
| ```sh | ||
| npx vitest run {{testExamples}} --reporter=json --outputFile {{resultPath}} |
There was a problem hiding this comment.
Non-blocking: The implementation's default command now includes --reporter=default as well as --reporter=json, so this default-command snippet is out of sync. Users copying the current docs would get JSON-only output and lose the normal Vitest console reporter; could we update the default/retry snippets and custom-command guidance to include both reporters?
There was a problem hiding this comment.
I found one blocker in the default Vitest command follow-up: the constructor, tests, and docs are now out of sync on whether the default includes both reporters.
Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:
Download the buildsworth logs from build 2542, then answer my questions about the findings.
|
|
||
| func NewVitest(v RunnerConfig) Vitest { | ||
| if v.TestCommand == "" { | ||
| v.TestCommand = "npx vitest run {{testExamples}} --reporter=default --reporter=json --outputFile {{resultPath}}" |
There was a problem hiding this comment.
Blocking: This default is now --reporter=default --reporter=json, but TestNewVitest still expects the JSON-only command and docs/vitest.md documents the same JSON-only default/retry commands. As written, the default-case assertion fails and the user-facing docs don't describe the command this constructor actually uses. Could you update the expected defaults and docs alongside this change?
There was a problem hiding this comment.
I found two blockers: the retry path can overwrite first-attempt results with Vitest's filter-skipped entries, and the default-command test expectations are now stale. I also left one docs sync note.
Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:
Download the buildsworth logs from build 2540, then answer my questions about the findings.
| Path: testPath, | ||
| } | ||
|
|
||
| result.RecordTestResult(testCase, status) |
There was a problem hiding this comment.
Blocking: Vitest includes tests filtered out by --testNamePattern in the JSON report as status: "skipped". Because retries pass the same RunResult back through this method, this unconditional record overwrites first-attempt results for tests that were not retried. For example, retrying (multi fails) in a file with sibling multi passes emits multi passes as skipped, so the final bktec result changes that previously-passed test to skipped. Could we ignore Vitest's filter-skipped assertions on retry unless they correspond to one of the retry testCases?
| TestCommand: "npx vitest run {{testExamples}} --reporter=json --outputFile {{resultPath}}", | ||
| TestFilePattern: "**/{__tests__/**/*,*.spec,*.test}.{ts,js,tsx,jsx}", | ||
| TestFileExcludePattern: "", | ||
| RetryTestCommand: "npx vitest run --testNamePattern '{{testNamePattern}}' --reporter=json --outputFile {{resultPath}}", |
There was a problem hiding this comment.
Blocking: NewVitest now defaults both commands to include --reporter=default, but this expectation still omits it, so TestNewVitest will fail once the Go tests run. Could we update the expected defaults here too?
| TestCommand: "npx vitest run {{testExamples}} --reporter=json --outputFile {{resultPath}}", | |
| TestFilePattern: "**/{__tests__/**/*,*.spec,*.test}.{ts,js,tsx,jsx}", | |
| TestFileExcludePattern: "", | |
| RetryTestCommand: "npx vitest run --testNamePattern '{{testNamePattern}}' --reporter=json --outputFile {{resultPath}}", | |
| TestCommand: "npx vitest run {{testExamples}} --reporter=default --reporter=json --outputFile {{resultPath}}", | |
| TestFilePattern: "**/{__tests__/**/*,*.spec,*.test}.{ts,js,tsx,jsx}", | |
| TestFileExcludePattern: "", | |
| RetryTestCommand: "npx vitest run --testNamePattern '{{testNamePattern}}' --reporter=default --reporter=json --outputFile {{resultPath}}", |
| By default, bktec runs Vitest with the following command: | ||
|
|
||
| ```sh | ||
| npx vitest run {{testExamples}} --reporter=json --outputFile {{resultPath}} |
There was a problem hiding this comment.
Non-blocking: The code default now includes --reporter=default as well as --reporter=json, so this user-facing default is out of sync. Could we update this command and the retry command below to match NewVitest?
There was a problem hiding this comment.
Existing default-command/test/docs blocker from the active buildsworth reviews is still unresolved; I’m not duplicating it inline here. I found one additional blocker in the npm fallback install path for the Vitest fixture.
Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:
Download the buildsworth logs from build 2539, then answer my questions about the findings.
| "node": ">=18" | ||
| } | ||
| }, | ||
| "node_modules/@rolldown/binding-darwin-arm64": { |
There was a problem hiding this comment.
Blocking: This lockfile only includes the Darwin ARM Rolldown native binding (grep 'node_modules/@rolldown/binding' returns just this entry), but Vitest/Vite needs the platform binding at runtime. On Linux, the npm fallback path in bin/setup installs from this lockfile and then npx vitest run ... fails with Cannot find module '@rolldown/binding-linux-x64-gnu'. Could we regenerate the npm lockfile so the Linux binding is present too, or drop it if Yarn is the intended installer?
Interesting that the last few commits were pushed by @buildkite-systems 🤔 therefore the build is blocked. |
|
@nprizal yeah, that's on me; I was setting something up in another tab and commented on your comments as buildkite-systems 😬 |
Description
Currently folks need to use the Jest runner with Vitest, as Vitest supports the Jest shape of JSON, however Vitest is (arguably) becoming more popular and offers some benefits over Jest, like explicit
skippedstatus.Context
This was raised by a customer as an enhancement on the engine, rather than using Jest.
Changes
BUILDKITE_TEST_ENGINE_RUNNER=vitestParseJestReportfunction for Jest and Vitest to share, with more generic erroring (removedJest)vitestto config locationsTesting
go test ./...with targeted testing passes, full test suite fails locally as it looks to use some CI specific function