webext-bridge icon indicating copy to clipboard operation
webext-bridge copied to clipboard

test: add unit tests generated by ToTheos

Open ToTheos-Dev opened this issue 6 months ago • 0 comments

AI-Generated Unit Tests

This PR adds AI-generated unit tests to improve coverage and ensure key functionality is tested.

Test coverage summary
Statements : 74.71% ( 325/435 )
Branches   : 51.26% ( 122/238 )
Functions  : 69.52% ( 73/105 )
Lines      : 74.93% ( 302/403 )

Coverage metrics generated by Jest, an open-source JavaScript testing framework.
Test files and commits
  • test: add config
  • test: add src/types.test.ts
  • test: add src/content-script.test.ts
  • test: add src/index.test.ts
  • test: add src/popup.test.ts
  • test: add src/devtools.test.ts
  • test: add src/internal/delivery-logger.test.ts
  • test: add src/internal/types.test.ts
  • test: add src/internal/port-message.test.ts
  • test: add src/internal/endpoint.test.ts
  • test: add src/internal/connection-args.test.ts
  • test: add src/internal/post-message.test.ts
  • test: add src/internal/persistent-port.test.ts
  • test: add src/internal/message-port.test.ts
  • test: add src/internal/is-internal-endpoint.test.ts
  • test: add src/internal/endpoint-fingerprint.test.ts
  • test: add src/internal/stream.test.ts
  • test: add src/internal/endpoint-runtime.test.ts
  • test: add src/window.test.ts
  • test: add src/background.test.ts
  • test: add src/options.test.ts
  • test: add src/__mocks__/nanoevents.test.js
  • test: add src/__mocks__/tiny-uid.test.js
  • test: add src/__mocks__/serialize-error.test.js
How to run tests

Jest is included as a dev dependency.

Run tests directly

./node_modules/.bin/jest

Optional: add npm scripts

You can add convenient scripts to package.json:

{
  "scripts": {
    "test": "jest",
    "test:watch": "jest --watch",
    "test:coverage": "jest --coverage --coverageReporters=text-summary"
  }
}

Usage examples

Run tests once:

pnpm run test

Run tests in watch mode during development:

pnpm run test:watch

Run tests with coverage summary:

pnpm run test:coverage

This contribution was created with assistance from ToTheos (https://totheos.com) to support test generation, code refactoring, and pull request preparation for an open-source codebases.

The tool was used to automate routine software development tasks.

ToTheos-Dev avatar May 21 '26 03:05 ToTheos-Dev