refactor: port remaining karma tests#7489
Conversation
There was a problem hiding this comment.
5 issues found across 53 files
Confidence score: 4/5
- This PR is likely safe to merge, with issues concentrated in tests rather than production code and severities staying in the low range (3–4/10).
- The most important gap is in
tests/unit/utils/endsWith.test.js: it appears to duplicatekindOfcoverage, leavingutils.endsWithbehavior unverified and reducing confidence against regressions. - Several test assertions/mocks could mask real failures (negative throw usage in
tests/unit/helpers/validator.test.js, ignored headers intests/browser/transform.browser.test.js, and baseURL composition not actually exercised intests/unit/adapters/fetch.test.js). - Pay close attention to
tests/unit/utils/endsWith.test.js,tests/unit/helpers/validator.test.js,tests/browser/transform.browser.test.js,tests/unit/adapters/fetch.test.js,tests/unit/utils/toArray.test.js- tighten test intent and assertions so coverage matches the behaviors being validated.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/unit/helpers/validator.test.js">
<violation number="1" location="tests/unit/helpers/validator.test.js:34">
P2: Use `.not.toThrow()` here; passing a specific `Error` to a negative throw assertion can let other thrown errors slip through and falsely pass the test.</violation>
</file>
<file name="tests/unit/utils/endsWith.test.js">
<violation number="1" location="tests/unit/utils/endsWith.test.js:4">
P2: `endsWith.test.js` duplicates `kindOf` tests, so it adds redundant coverage and leaves `utils.endsWith` untested.</violation>
</file>
<file name="tests/unit/utils/toArray.test.js">
<violation number="1" location="tests/unit/utils/toArray.test.js:6">
P3: Test names reference `kindOf`/object tags, but this file tests `toArray`; rename the suite/case to reflect actual behavior.</violation>
</file>
<file name="tests/browser/transform.browser.test.js">
<violation number="1" location="tests/browser/transform.browser.test.js:257">
P2: `respondWith` is called with `headers`, but the mock only consumes `responseHeaders`, so this header block is ignored.</violation>
</file>
<file name="tests/unit/adapters/fetch.test.js">
<violation number="1" location="tests/unit/adapters/fetch.test.js:466">
P2: This test no longer verifies baseURL/url combination because it uses an absolute request URL. Use a client whose `baseURL` points to the started server and request with a relative path.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
8 issues found across 37 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/smoke/cjs/tests/files.smoke.test.js">
<violation number="1" location="tests/smoke/cjs/tests/files.smoke.test.js:3">
P1: `expect` is imported from Mocha but used with Jest/Vitest matchers (`toBe`, `toEqual`, `toContain`), which will break these smoke tests at runtime.</violation>
</file>
<file name="tests/smoke/cjs/tests/http2.smoke.test.js">
<violation number="1" location="tests/smoke/cjs/tests/http2.smoke.test.js:2">
P2: `expect` is being imported from `mocha`, but Mocha doesn’t export an `expect` helper. These assertions will throw at runtime. Import `expect` from an assertion library (e.g., `chai`) instead.</violation>
</file>
<file name="tests/smoke/cjs/tests/instance.smoke.test.js">
<violation number="1" location="tests/smoke/cjs/tests/instance.smoke.test.js:4">
P2: `expect` isn’t exported by Mocha, so these tests will crash at runtime. Import `expect` from the assertion library (e.g., chai) instead.</violation>
</file>
<file name="tests/smoke/cjs/tests/timeout.smoke.test.js">
<violation number="1" location="tests/smoke/cjs/tests/timeout.smoke.test.js:4">
P2: `mocha` doesn’t export an `expect` assertion helper. This import leaves `expect` undefined, so the test will throw when it reaches the first `expect(...)` call. Import an assertion library (e.g., `expect` or `chai`) separately and only get `describe/it` from Mocha.</violation>
</file>
<file name="tests/smoke/cjs/tests/urlencode.smoke.test.js">
<violation number="1" location="tests/smoke/cjs/tests/urlencode.smoke.test.js:4">
P2: `expect` is not exported by mocha, so this import leaves `expect` undefined and the assertions will fail. Import `expect` from the assertion library used in the repo (e.g., chai).</violation>
</file>
<file name="tests/smoke/esm/vitest.config.js">
<violation number="1" location="tests/smoke/esm/vitest.config.js:11">
P1: Vitest configuration includes path pattern that doesn't match actual test file locations</violation>
</file>
<file name="tests/smoke/cjs/tests/headers.smoke.test.js">
<violation number="1" location="tests/smoke/cjs/tests/headers.smoke.test.js:4">
P2: Mocha does not export `expect`, so destructuring it from `require('mocha')` leaves `expect` undefined and the assertions will throw. Import `expect` from your assertion library (e.g., chai/expect) and ensure it’s configured instead of pulling it from Mocha.</violation>
</file>
<file name="tests/smoke/cjs/tests/progress.smoke.test.js">
<violation number="1" location="tests/smoke/cjs/tests/progress.smoke.test.js:3">
P1: `expect` is imported from `mocha`, but Mocha does not export an assertion `expect`; these test assertions will fail at runtime.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
3 issues found across 5 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/smoke/cjs/package.json">
<violation number="1" location="tests/smoke/cjs/package.json:7">
P1: 12 orphaned JavaScript test files in tests/smoke/cjs/tests/ are no longer executed after package.json pattern change</violation>
<violation number="2" location="tests/smoke/cjs/package.json:13">
P1: `file:` dependency points to a single JS file instead of a package path/tarball, which can break `npm install` for the CJS smoke tests.</violation>
</file>
<file name="tests/smoke/cjs/tests/cancel.smoke.test.cjs">
<violation number="1" location="tests/smoke/cjs/tests/cancel.smoke.test.cjs:39">
P2: These cancellation tests can pass without proving the request rejected. Add an explicit failure on the success path (or assert rejection directly) so regressions in AbortController cancellation are caught.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/workflows/run-ci.yml">
<violation number="1" location=".github/workflows/run-ci.yml:73">
P2: Use `npm ci` here to keep CJS smoke test installs reproducible and aligned with the lockfile in CI.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/smoke/cjs/package.json">
<violation number="1" location="tests/smoke/cjs/package.json:13">
P1: Dead CJS smoke test files (.js extension) never executed by mocha runner</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
2 issues found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/smoke/cjs/tests/cancel.smoke.test.cjs">
<violation number="1" location="tests/smoke/cjs/tests/cancel.smoke.test.cjs:37">
P2: Node version gating uses lexicographic string comparison; parse the major version numerically to avoid incorrect skip behavior.</violation>
<violation number="2" location="tests/smoke/cjs/tests/cancel.smoke.test.cjs:38">
P2: `this.skip()` is used inside arrow-function tests, so the skip path throws instead of skipping on unsupported runtimes.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/smoke/cjs/tests/cancel.smoke.test.cjs">
<violation number="1" location="tests/smoke/cjs/tests/cancel.smoke.test.cjs:38">
P2: `return` here causes a false-positive pass on Node <16 instead of a skipped test. Use Mocha skip semantics so unsupported-runtime cases are reported as pending.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
2 issues found across 13 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/smoke/cjs/tests/formData.smoke.test.cjs">
<violation number="1" location="tests/smoke/cjs/tests/formData.smoke.test.cjs:61">
P1: `this.skip()` is called inside an arrow-function `describe` callback, so the suite cannot be skipped and will error on Node < 18.</violation>
</file>
<file name="tests/smoke/cjs/tests/fetch.smoke.test.cjs">
<violation number="1" location="tests/smoke/cjs/tests/fetch.smoke.test.cjs:29">
P2: `this.skip()` is used inside an arrow-function `describe` callback, so the Node<18 guard throws instead of skipping the suite.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
6 issues found across 21 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/smoke/esm/tests/cancel.smoke.test.js">
<violation number="1" location="tests/smoke/esm/tests/cancel.smoke.test.js:39">
P2: The new `try/catch` pattern weakens the test: it does not fail when cancellation does not reject as expected. Keep an explicit `.rejects` assertion (or fail explicitly after `await request`) so these tests cannot pass on unexpected success paths.</violation>
</file>
<file name="tests/smoke/esm/tests/interceptors.smoke.test.js">
<violation number="1" location="tests/smoke/esm/tests/interceptors.smoke.test.js:29">
P2: Using `||` here changes defaulting semantics and treats intentionally empty payloads as missing. Use a default parameter (or `??`) to preserve the previous behavior.</violation>
</file>
<file name=".github/workflows/run-ci.yml">
<violation number="1" location=".github/workflows/run-ci.yml:112">
P1: The ESM smoke-test workflow calls a non-existent npm script (`test:smoke:esm:mocha`), so the new CI job will fail immediately.</violation>
</file>
<file name="tests/smoke/esm/tests/instance.smoke.test.js">
<violation number="1" location="tests/smoke/esm/tests/instance.smoke.test.js:29">
P2: Use nullish fallback instead of truthiness fallback so valid falsy response bodies (like empty string) are preserved.</violation>
</file>
<file name="tests/smoke/esm/tests/error.smoke.test.js">
<violation number="1" location="tests/smoke/esm/tests/error.smoke.test.js:49">
P2: Use an undefined/null check for `body` instead of a truthy check; current logic masks explicit empty bodies.</violation>
</file>
<file name="tests/smoke/esm/tests/timeout.smoke.test.js">
<violation number="1" location="tests/smoke/esm/tests/timeout.smoke.test.js:40">
P2: Using `||` for `body` fallback incorrectly overrides explicit falsy payloads (e.g. empty string). Preserve only the `undefined` defaulting behavior here.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Summary by cubic
Ports remaining Karma tests to
vitestwithplaywrightheadless (Chromium/Firefox/WebKit), adds ESM (vitest) and CJS (mocha@9) smoke suites to validate dist exports and ESM/CJS parity, and stabilizes CI on Node 24. No runtime changes.Description
browser-headlessproject invitest.config.jsandtest:vitest:browser:headlessscript; ported Karma specs totests/browser/**/*.browser.test.js; removed legacysmoke.browser.test.jsand unusedenhanceError.spec.js.LOCAL_SERVER_URL.tests/smoke/esm(vitest) and CJS smoke suite attests/smoke/cjs(mocha@9) to verify dist exports and ESM/CJS behavior parity.24.x, installplaywrightwith system deps, runvitestunit + browser headless; refined steps/commands for stability.docs/in.gitignore.vitest+playwright.AbortController/fetchare missing.Docs
npm run test:vitest:unit,npm run test:vitest:browser,npm run test:vitest:browser:headless.cd tests/smoke/esm && npm i && npm run test:smoke:esm:vitestcd tests/smoke/cjs && npm i && npm run test:smoke:cjs:mocha.gitignorenow ignoresdocs/.Testing
fetch/http), core, helpers, utils, and static API; stabilized with per‑suite fixed ports; added Node ≤16 skip guards and fetch gating.Written for commit 91937d7. Summary will update on new commits.