Skip to content

chore: Split unit and e2e tests into separate CI jobs#651

Merged
jancurn merged 2 commits into
masterfrom
claude/consolidate-github-actions-tests-b6npb
May 11, 2026
Merged

chore: Split unit and e2e tests into separate CI jobs#651
jancurn merged 2 commits into
masterfrom
claude/consolidate-github-actions-tests-b6npb

Conversation

@jancurn
Copy link
Copy Markdown
Member

@jancurn jancurn commented Apr 22, 2026

Summary

Rebuilt on top of v3.0 (master). Mirrors the layout used in apify/mcpc: split unit tests from e2e tests so the unit suite is fast and easy to run as a smoke check, while the heavier e2e suite is its own job.

Master already runs the matrix on Node.js 20/22/24 / ubuntu-24.04, so this PR no longer touches the Node version policy or the Docker harness — just the test layout and the workflow shape.

Changes

Test layout (test/)

  • test/unit/tools.js — utility-function tests (no network/servers)
  • test/e2e/*.js — server-/network-backed integration tests (moved from test/*.js); SSL fixtures (ssl.key, ssl.crt) move alongside them, so import.meta.dirname keeps working
  • test/utils/ — shared helpers (unchanged); e2e files now import from ../utils/...
  • All relative imports retargeted ('../src/...''../../src/...')

npm scripts (package.json)

  • test:unitmocha 'test/unit/**/*.js' (no --insecure-http-parser, no nyc; the unit suite doesn't need them)
  • test:e2enyc cross-env NODE_OPTIONS=--insecure-http-parser mocha 'test/e2e/**/*.js'
  • test — runs both as one mocha invocation, preserving npm test -- <file> for the Docker entrypoint

CI workflow (.github/workflows/check.yaml)

  • unit — matrix on Node.js [20, 22, 24], runs-on: ubuntu-24.04, fail-fast: false. Lint runs once on Node.js 24.
  • e2e — single job, Node.js 24 / ubuntu-24.04, sets the localhost-test hosts entry, then npm run test:e2e.
  • workflow_call retained, so release.yaml keeps working.

Docs

  • test/README.md updated for the new layout / commands.

What I dropped from the previous attempt

The earlier revision of this PR predated v3.0; v3.0 already absorbed several things I had patched, so they're gone now:

  • Bumping the Node.js matrix from 14/16/18 → 20/22/24 (master did it)
  • Updating test/Dockerfile and scripts/test-docker-all.sh to Node 20/22/24 (master did it)
  • The count_target_bytes.ts lint fix (master removed the typeSocket helper entirely in chore: remove typeSocket assertion helper #653)
  • "exit": true in .mocharc.json and pinning e2e to Node 18 / ubuntu-22.04 (master's e2e suite already passes on Node 24 / ubuntu-24.04 in ~3 min, so neither workaround is needed)

Test plan

  • npm run lint clean
  • npm run test:unit passes locally (4/4)
  • mocha --dry-run test/e2e/**/*.js discovers 2186 tests
  • Spot-checked test/e2e/ee-memory-leak.js and test/e2e/http-agent.js pass with the new import paths
  • CI: unit matrix green on Node 20/22/24
  • CI: e2e job green on Node 24

https://claude.ai/code/session_01QyJuystdjqYTCFBNW7Z3XD

@jancurn jancurn changed the title Reorganize tests into unit and e2e suites, update Node.js versions Split unit/e2e tests, run unit tests across Node.js 20/22/24 Apr 23, 2026
@jancurn
Copy link
Copy Markdown
Member Author

jancurn commented Apr 23, 2026

Hey @jirimoravcik @bliuchak I consolidated the unit and e2e tests, as well as GitHub Actions, it looked somewhat messy. As a follow up, I'd like to introduce support + tests for Bun, and enable higher versions of Node in tests.

@bliuchak
Copy link
Copy Markdown
Contributor

@jancurn hey, thanks for PR. If you don't mind I'd merge it after #637 is done. We've already made the main changes. The only thing left is to merge this and make a release.

@jancurn
Copy link
Copy Markdown
Member Author

jancurn commented Apr 23, 2026

@bliuchak but looking at the epic, i don't see any PRs, just issues. So perhaps this is good to go now?

@bliuchak
Copy link
Copy Markdown
Contributor

bliuchak commented Apr 24, 2026

Not sure why GH don't show these PR 😞

@jancurn here they are:

They need to be merged in the PR train as they depend on each other. Honestly, there is not much work left; I just need to find some time to finish it.

@jancurn
Copy link
Copy Markdown
Member Author

jancurn commented Apr 24, 2026

Cheers, fair enough, will wait with this

Reorganises tests to mirror apify/mcpc:

- Move pure unit tests to `test/unit/` (`tools.js`) and the
  network/server-backed tests to `test/e2e/`. Shared helpers stay in
  `test/utils/`. SSL fixtures move alongside the e2e tests.
- Add `test:unit` and `test:e2e` npm scripts; `npm test` still runs both
  suites under nyc with the `--insecure-http-parser` Node option that
  the e2e suite needs.
- Split the Check workflow into a `unit` job that runs the matrix
  (Node.js 20/22/24) on ubuntu-24.04 with `fail-fast: false` plus lint
  on Node.js 24, and a single `e2e` job that runs on Node.js 24 with
  the `localhost-test` hosts entry.
@jancurn jancurn force-pushed the claude/consolidate-github-actions-tests-b6npb branch from bc70210 to fed0d26 Compare May 8, 2026 11:12
@jancurn jancurn changed the title Split unit/e2e tests, run unit tests across Node.js 20/22/24 Split unit and e2e tests into separate CI jobs May 8, 2026
@jancurn jancurn changed the title Split unit and e2e tests into separate CI jobs chore: Split unit and e2e tests into separate CI jobs May 8, 2026
@jancurn
Copy link
Copy Markdown
Member Author

jancurn commented May 8, 2026

@bliuchak I believe this is now ready for review

@bliuchak bliuchak requested a review from daniil-poletaev May 11, 2026 09:20
@bliuchak
Copy link
Copy Markdown
Contributor

@jancurn thanks, i'll take a look into it!

Copy link
Copy Markdown
Member

@jirimoravcik jirimoravcik left a comment

Choose a reason for hiding this comment

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

One comment, otherwise looks good

Comment on lines 10 to +38
@@ -33,8 +34,28 @@ jobs:
if: ${{ matrix.node-version == 24 }}
run: npm run lint

- name: Run unit tests
run: npm run test:unit
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This job still contains lint, it should either be reflected in the name or separated into another job

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call — extracted lint into its own dedicated Lint job alongside Unit tests and E2E tests in 31d794d.


Generated by Claude Code

Per review on #651: the unit job ran lint on Node 24 only, which made
the job name misleading and coupled a lint failure to unit-test
reporting on that one matrix entry. Lint now runs as a dedicated job
alongside unit and e2e.
@jancurn jancurn requested a review from jirimoravcik May 11, 2026 10:51
Copy link
Copy Markdown

@daniil-poletaev daniil-poletaev left a comment

Choose a reason for hiding this comment

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

Looks good, thank you! 🔥

@jancurn jancurn merged commit 6039501 into master May 11, 2026
7 checks passed
@jancurn jancurn deleted the claude/consolidate-github-actions-tests-b6npb branch May 11, 2026 11:08
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.

6 participants