Skip to content

ci(test): migrate from jest to vitest - #13989

Merged
bzp2010 merged 1 commit into
apache:masterfrom
bzp2010:bzp/ci-move-jest-to-vitest
Sep 28, 2026
Merged

bzp2010 merged 1 commit into
apache:masterfrom
bzp2010:bzp/ci-move-jest-to-vitest

Conversation

@bzp2010

@bzp2010 bzp2010 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

Migrate the TypeScript test suite under t/ from Jest (with ts-jest) to Vitest. The .spec.mts suffix only existed to satisfy ts-jest's ESM mode, so the specs are now plain .ts files, which are ESM by default because t/package.json already sets "type": "module".

Changes:

  • Dependencies: remove jest, ts-jest, @jest/globals, @types/jest and ts-node (it was only used to load jest.config.ts), and add vitest. The test script becomes vitest run --reporter=verbose, so NODE_OPTIONS=--experimental-vm-modules is no longer needed.
  • Config: jest.config.ts is replaced by vitest.config.ts with globals: true and include: ['**/*.{spec,test}.ts']. tsconfig.json uses types: ["node", "vitest/globals"] (the setup documented by Vitest) and moduleResolution: "bundler", so describe, it, expect, vi and friends are available without imports.
  • Specs: drop the @jest/globals imports, replace jest.setTimeout(15000) with vi.setConfig({ testTimeout: 15000 }), and rename *.spec.mts to *.spec.ts. plugin/grpc-web/client.cts is not a Vitest spec (it is run by tsx from grpc-web.t), so it is left as is.
  • .t files: the Test::Nginx cases used to assert Jest's output (PASS <file> and Tests: N passed, N total), which Vitest does not print. They now match Vitest's summary (Test Files 1 passed (1) and Tests N passed (N)) and run with --no-color, because ANSI colors leak into the captured output under prove and break the regexes.
  • CI: update the "jest test suite" comments in the two runner scripts, and drop the now dead *.mts entry from the codespell skip list in lint.yml.

Notes for reviewers:

  • ts-jest used to type check the specs, Vitest does not. tsc --noEmit -p t still reports no errors in the project files.
  • Ran metadata.t, standalone.t and websocket-proxy.t against a local etcd, all pass.

Which issue(s) this PR fixes:

#13939 (comment)

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@shreemaan-abhishek shreemaan-abhishek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lago tests are still being skipped pls fix this first.

plan(skip_all => 'skip test case');

@bzp2010

bzp2010 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

@shreemaan-abhishek

The issues with the lago tests will not be fixed in this PR.
This PR does not help resolve the tests that currently fail to run, because the underlying conditions have not changed: dependencies are still downloaded during test execution and may fail.

The timeout duration for Node.js child processes is unpredictable, but test::nginx enforces an empirical value and does not support proper retries—and that is the crux of the problem. Simply migrating to vitest does not guarantee that lago tests will always pass.

This PR is merely the first part of a broader refactoring, serving as the starting point for splitting the TypeScript-based tests from test::nginx. Currently, the tests rely on test::nginx to prepare the nginx.conf configuration and start OpenResty; the TypeScript tests are simply embedded as a single test case within test::nginx and run as a subprocess.
TypeScript lacks both a proper runtime and the ability to directly manage OpenResty’s configuration and lifecycle, which requires systematic improvements.

@bzp2010
bzp2010 merged commit d97d5f7 into apache:master Sep 28, 2026
24 of 25 checks passed
@bzp2010
bzp2010 deleted the bzp/ci-move-jest-to-vitest branch September 28, 2026 04:42
@bzp2010
bzp2010 restored the bzp/ci-move-jest-to-vitest branch September 28, 2026 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants