larsthorup / mocha-vite-puppeteer

Run your Mocha tests with Vite bundler and Puppeteer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vite-browser-external:crypto' does not provide an export named 'randomBytes'

fatso83 opened this issue · comments

I got this project up this time, but Vite is throwing up a humongous stack trace about some Vite related export being missing:

SyntaxError: The requested module '/@id/__vite-browser-external:crypto' does not provide an export named 'randomBytes'
Full output from running the command line
$ $(pnpm bin)/mocha-vite-puppeteer --port 5005
Pre-bundling dependencies:
  moment/locale/nb
  moment
  react
  react-dom
  tcomb/lib/installTypeFormatter
  (...and 191 more)
(this will be run only when your dependencies or config have changed)

  vite v2.4.4 dev server running at:

  > Local: http://localhost:5005/
  > Network: use `--host` to expose
[vite] connecting...
[vite] connected.
4:48:23 PM [vite] new dependencies found: chai, updating...

4:48:24 PM [vite] ✨ dependencies updated, reloading page...
(node:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/test/stub-object-helpers.ts net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:96121) 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:96121) [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:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/src/store/users/users-reducer.ts net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(node:96121) 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:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/@fs/home/my-user/code/my-project/frontend/node_modules/.pnpm/chai@4.2.0/node_modules/chai/index.js net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(node:96121) 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)
[vite] connecting...
[vite] connected.
4:48:24 PM [vite] new dependencies found: sinon, updating...

4:48:26 PM [vite] ✨ dependencies updated, reloading page...

(node:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/@fs/home/my-user/code/my-project/frontend/node_modules/.vite/lodash_map.js?v=564d2402 net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(node:96121) 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: 4)
(node:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/@fs/home/my-user/code/my-project/frontend/node_modules/.vite/lodash_keyBy.js?v=564d2402 net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(node:96121) 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: 5)
(node:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/@fs/home/my-user/code/my-project/frontend/node_modules/.vite/@reduxjs_toolkit.js?v=564d2402 net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(node:96121) 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: 6)
(node:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/src/types/domain-type-interfaces.ts net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(node:96121) 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: 7)
(node:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/@fs/home/my-user/code/my-project/frontend/node_modules/.vite/chunk-IHTDASF6.js?v=564d2402 net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(node:96121) 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: 8)
(node:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/src/store/users/users-actions.ts net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(node:96121) 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: 9)
(node:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/@id/__vite-browser-external:crypto net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(node:96121) 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: 10)
(node:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/@fs/home/my-user/code/my-project/frontend/node_modules/.pnpm/sinon@8.1.1/node_modules/sinon/pkg/sinon-esm.js net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(node:96121) 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: 11)
(node:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/src/types/enums.ts net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(node:96121) 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: 12)
(node:96121) UnhandledPromiseRejectionWarning: Error: http://localhost:5005/src/utils/authorization-util.ts net::ERR_ABORTED
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:74:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:153:106
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at NetworkManager.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
(node:96121) 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: 13)
[vite] connecting...
[vite] connected.

(node:96121) UnhandledPromiseRejectionWarning: Error: SyntaxError: The requested module '/@id/__vite-browser-external:crypto' does not provide an export named 'randomBytes'
    at file:///home/my-user/code/my-project/frontend/node_modules/.pnpm/mocha-vite-puppeteer@1.8.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/mocha-vite-puppeteer/cli.js:82:11
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at Page.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at Page._handleException (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:942:14)
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:161:66
    at /home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/my-user/code/my-project/frontend/node_modules/.pnpm/puppeteer@10.2.0_c70f8fc5586dd378b8c866035dbe710b/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
(node:96121) 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: 14)

So I see from the error that this comes from the browser side (page.on('pageerror', ...) on line 82), but something seems to be different given that Vite does not usually complain ...? That being said, Vite usually loads the "normal" bundle, not a test module, so it's not 1:1.

I also researched the error a bit, and from reading similar stories from Svelte (also using Rollup) it seems to be caused by some module using crypto.randomBytes() from Node, which obviously needs a shim, somehow.

Given that find, I am not quite sure this issue belongs here, but thought I would mention it as something that might be beneficial for other users. And I will paste a solution, if/when I find one.

Success 🥳

Followed my own analysis, grepped for modules using randomBytes and replaced the module with a browser-compatible NPM module:

$(pnpm bin)/mocha-vite-puppeteer --port 5005

  vite v2.4.4 dev server running at:

  > Local: http://localhost:5005/
  > Network: use `--host` to expose
[vite] connecting...
[vite] connected.



  selectors
    getUsersByHpr
      ✔ should return an empty list of users when no match is found
      ✔ should return an list of all users matching hpr number


  2 passing (5ms)

Diff required

$ git diff test package.json
diff --git a/frontend/code/clinic/test/stub-object-helpers.ts b/frontend/code/clinic/test/stub-object-helpers.ts
index 4163fe4ec..4310b6a7a 100644
--- a/test/stub-object-helpers.ts
+++ b/test/stub-object-helpers.ts
@@ -1,5 +1,4 @@
-import { randomBytes } from 'crypto'
-
+import randomBytes  from 'randombytes'
 import * as sinon from 'sinon'
 import { SinonSpy } from 'sinon'
 
diff --git a/package.json b/package.json
index 4d52035a3..c60d81dcb 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -63,6 +63,7 @@
   "devDependencies": {
     "@babel/cli": "^7.8.4",
@@ -182,6 +183,7 @@
     "prettier": "^2.2.1",
     "prop-types": "^15.7.2",
     "proxyquire": "^1.8.0",
+    "randombytes": "^2.1.0",
     "regenerator-runtime": "~0.13.5",