bzp2010 opened a new pull request, #13989:
URL: https://github.com/apache/apisix/pull/13989

   ### 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. In `openapi-to-mcp-interop.t` the Vitest case passes, and the 
remaining `[error]` log assertions fail only because of Lua dependencies 
missing in my local environment (`resty.saml`, `resty.ldap.client`, 
`libpcre.so.3`). `lago.spec.ts` and `mcp-bridge.spec.ts` need docker and an MCP 
bridge server, so I could only confirm that they load and start under Vitest.
   
   #### Which issue(s) this PR fixes:
   
   https://github.com/apache/apisix/pull/13939#discussion_r4022330605
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] 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
   - [x] I have verified that this change is backward compatible (If not, 
please discuss on the [APISIX mailing 
list](https://github.com/apache/apisix/tree/master#community) first)
   
   <!--
   
   Note
   
   1. Mark the PR as draft until it's ready to be reviewed.
   2. Always add/update tests for any changes unless you have a good reason.
   3. Always update the documentation to reflect the changes made in the PR.
   4. Make a new commit to resolve conversations instead of `push -f`.
   5. To resolve merge conflicts, merge master instead of rebasing.
   6. Use "request review" to notify the reviewer after making changes.
   7. Only a reviewer can mark a conversation as resolved.
   
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to