Skip to content

test(browser-logs): migrate tests to node:test#3095

Open
bennypowers wants to merge 2 commits into
masterfrom
migrate/browser-logs-node-test
Open

test(browser-logs): migrate tests to node:test#3095
bennypowers wants to merge 2 commits into
masterfrom
migrate/browser-logs-node-test

Conversation

@bennypowers
Copy link
Copy Markdown
Member

Summary

  • Migrate 1 test file (33 tests) from mocha/chai to node:test/node:assert/strict
  • Replace require.resolve with createRequire(import.meta.url) for ESM compatibility
  • Replace __dirname with import.meta.dirname
  • Replace (window as any)._serialize with window['_serialize'] in page.evaluate callbacks to avoid strip-types whitespace shifting Chrome stack trace column numbers
  • Use { ...deserialized } spread for class instance deepEqual since deepStrictEqual checks constructor (chai eql did not)
  • Update error stack column assertions (2:29 -> 2:23 etc.) to match strip-types function serialization
  • Remove leftover @esm-bundle/chai devDependency
  • Replace src/ imports with dist/ imports, separate type-only imports with import type

Test plan

  • All 33 tests pass locally on Node 22.22.3 (3 consecutive runs, no flakiness)
  • Lint passes
  • Build passes

Replace mocha/chai with node:test, node:assert/strict across 1 test
file (33 tests).

Key changes:
- chai expect() -> node:assert/strict
- `require.resolve` -> createRequire(import.meta.url)
- `__dirname` -> import.meta.dirname
- src/ imports -> dist/ imports for native type stripping
- `this.timeout()` -> describe timeout option
- `(window as any)` -> window['_serialize'] in page.evaluate
  callbacks to avoid strip-types whitespace shifting Chrome
  stack trace column numbers
- deepEqual with class instances uses spread to plain object
  since deepStrictEqual checks constructor unlike chai eql
- Updated error stack column assertions to match strip-types
  function serialization format

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
No longer needed after migration to node:assert/strict.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 2, 2026

⚠️ No Changeset found

Latest commit: ff6742c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

1 participant