Skip to content

Conversation

@gnbm
Copy link

@gnbm gnbm commented Oct 24, 2025

Replace Karma (Jasmine) bundler tests with Jest + Puppeteer to keep real-browser parity while simplifying setup.

What is the current behavior?

  • Karma is legacy and adds infra complexity.
  • Jest + Puppeteer provides the same real-browser guarantees with simpler tooling and better DX.
  • Aligns with existing Stencil testing infra and conventions.

GitHub Issue Number: N/A

What is the new behavior?

What Changed

  • test/bundler/vite-bundle-test/vite-bundle.spec.ts

    • New Jest + Puppeteer test: launches headless Chromium, serves dist/, waits for hydration, asserts Shadow DOM text.
    • Uses Node’s node:http, node:fs, node:path for cross-platform static serving.
    • TypeScript with explicit Browser/Server types.
  • test/bundler/jest.config.js

    • Restored ts-jest config for TypeScript specs.
  • test/bundler/* package.json clean scripts

    • Replaced rm -rf with Node fs.rmSync for Windows/macOS/Linux compatibility.
  • test/bundler/readme.md

    • Updated docs to reflect Jest + Puppeteer approach.
  • Removed Karma files

    • test/bundler/karma.config.ts
    • test/bundler/karma-stencil-utils.ts
  • Root script (package.json)

    • Added test.jest.lowmem for CI/local stability (8GB heap, 50% workers).

Parity With Karma
✅ Real Chromium via Puppeteer (not jsdom)
✅ Static serving of Vite output, no dev-server coupling
✅ Shadow DOM assertions after hydration
✅ Cross-platform (Windows/macOS/Linux)

CI/Local Stability

  • Added npm run test.jest.lowmem:
    • node --max-old-space-size=8192 --experimental-vm-modules ./node_modules/jest/bin/jest.js --maxWorkers=50%
  • Mitigates Windows/CI memory pressure observed during large Jest runs.

Documentation

Does this introduce a breaking change?

  • Yes
  • No

Testing

  • From repo root:
    • Build: npm run build
    • Bundler tests (full flow): cd test/bundler && npm run start
    • Root Jest (stable mode): npm run test.jest.lowmem

Other information

Notes:

  • Playwright was evaluated; Jest + Puppeteer chosen for consistency with existing Stencil testing and minimal change footprint.
  • Verified on Windows; node: imports and Node static server ensure cross-platform behavior.

gnbm added 5 commits October 22, 2025 23:44
…S config\n\n- Serve Vite dist via Node static server (parity with Karma)\n- Real browser with Puppeteer; wait for .hydrated before asserting\n- Restore ts-jest config and explicit TS types\n- Keep node: imports and cross-platform clean scripts
@gnbm gnbm added the dependencies Pull requests that update a dependency file label Oct 24, 2025
gnbm added 23 commits October 24, 2025 13:40
…n- Force public registry and disable always-auth\n- Delete inherited auth token for registry\n- Write clean ~/.npmrc for job
… unsupported option errors\n\n- Avoid 'always-auth' setter; write exact keys to ~/.npmrc\n- Keep public registry and blank token
…to avoid E401\n\n- Write .npmrc in test/bundler and vite-bundle-test\n- Export NPM_* env vars to ensure no token is used
…running Jest on compiled output (no ts-jest install)
- Remove debug logging from vite-bundle.spec.ts (test is stable)
- Reduce wait timeouts back to 10s (original timeouts sufficient)
- Add .gitignore for CI-generated artifacts (dist-spec, jest.config.ci.js, tsconfig.test.json)
- Remove redundant puppeteer install step from CI workflow (already in root deps)
- Simplify Chrome download step to use existing puppeteer installation
Reinstall puppeteer explicitly before downloading Chrome to ensure
puppeteer-core is properly installed. In some CI environments, npm ci
doesn't correctly install peer dependencies, leading to module
resolution errors when Jest tries to require('puppeteer').
@gnbm gnbm marked this pull request as ready for review October 27, 2025 11:18
@gnbm gnbm requested a review from a team as a code owner October 27, 2025 11:18
@gnbm
Copy link
Author

gnbm commented Oct 27, 2025

@johnjenkins tried a different approach.
Some checks didn't run in the PR, but I lack context.
Hope someone can review this since I still have a lot to learn on this project :)

@johnjenkins
Copy link
Contributor

@johnjenkins tried a different approach. Some checks didn't run in the PR, but I lack context. Hope someone can review this since I still have a lot to learn on this project :)

Sorry - pipelines are not my strong-suite :/
Maybe github has some caching on the job names?

@gnbm
Copy link
Author

gnbm commented Oct 27, 2025

@johnjenkins tried a different approach. Some checks didn't run in the PR, but I lack context. Hope someone can review this since I still have a lot to learn on this project :)

Sorry - pipelines are not my strong-suite :/ Maybe github has some caching on the job names?

Mine neither. I'll wait for some feedback on this PR from the community. Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants