Skip to content

TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: base64url is thrown in vite dev server  #8

@stevez

Description

@stevez

How to reproduce:

  1. code example repo: https://github.com/stevez/playwright-test-coverage/tree/bgotink-coveage-lib-vite-integration
    git clone https://github.com/stevez/playwright-test-coverage.git
    git checkout bgotink-coveage-lib-vite-integration
  2. npm install
  3. npx playwright install
  4. npm run test

Then you will get following error:

(node:53635) UnhandledPromiseRejectionWarning: TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: base64url
at fromString (buffer.js:454:13)
at Function.from (buffer.js:308:12)
at getSourceMap (/Users/s5474013/github/playwright-test-coverage/node_modules/@bgotink/playwright-coverage/lib/data.js:51:26)
at CoverageWorker._CoverageWorker_convert (/Users/s5474013/github/playwright-test-coverage/node_modules/@bgotink/playwright-coverage/lib/worker.js:74:123)
(Use node --trace-warnings ... to show where the warning was created)
(node:53635) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:53635) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:53635) UnhandledPromiseRejectionWarning: TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: base64url
at fromString (buffer.js:454:13)
at Function.from (buffer.js:308:12)
at getSourceMap (/Users/s5474013/github/playwright-test-coverage/node_modules/@bgotink/playwright-coverage/lib/data.js:51:26)
at CoverageWorker._CoverageWorker_convert (/Users/s5474013/github/playwright-test-coverage/node_modules/@bgotink/playwright-coverage/lib/worker.js:74:123)
(node:53635) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:53635) UnhandledPromiseRejectionWarning: TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: base64url
at fromString (buffer.js:454:13)
at Function.from (buffer.js:308:12)
at getSourceMap (/Users/s5474013/github/playwright-test-coverage/node_modules/@bgotink/playwright-coverage/lib/data.js:51:26)
at CoverageWorker._CoverageWorker_convert (/Users/s5474013/github/playwright-test-coverage/node_modules/@bgotink/playwright-coverage/lib/worker.js:74:123)
(node:53635) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:53635) UnhandledPromiseRejectionWarning: TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: base64url
at fromString (buffer.js:454:13)
✓ [Chrome] › e2e/App2.test.ts:7:1 › use Turquoise as a background color (2s)
at getSourceMap (/Users/s5474013/github/playwright-test-coverage/node_modules/@bgotink/playwright-coverage/lib/data.js:51:26)
at CoverageWorker._CoverageWorker_convert (/Users/s5474013/github/playwright-test-coverage/node_modules/@bgotink/playwright-coverage/lib/worker.js:74:123)
(node:53635) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see h
✓ [Chrome] › e2e/App.test.ts:11:1 › use Red as a background color (477ms)

3 passed (4s)
Error in reporter TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: base64url
at fromString (buffer.js:454:13)
at Function.from (buffer.js:308:12)
at getSourceMap (/Users/s5474013/github/playwright-test-coverage/node_modules/@bgotink/playwright-coverage/lib/data.js:51:26)
at CoverageWorker._CoverageWorker_convert (/Users/s5474013/github/playwright-test-coverage/node_modules/@bgotink/playwright-coverage/lib/worker.js:74:123)

====================================
I understand your library works in the webpack dev server: I have another branch confirmed this, even the coverage number is different with the number in the main branch: (https://github.com/stevez/playwright-test-coverage/tree/bgotink-coverage-lib),
But since I want to use the vite server, which source code are not bundled, I think this might cause the issue? I am not familiar with the v8 coverage format yet, maybe you can provide some insight?
My original plan was simple: in order to support coverage in vite, playwright tests just output the v8 format json file, then use c8 to generate the istanbul result -- it sounds easy, but the number is not correct, you can check my another branch for the demo:
https://github.com/stevez/playwright-test-coverage/tree/v8-coverage.

Either you can fix the issue to support vite, or any suggestion will be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions