Skip to content

vitest browser __vi_esm_0__.default is not a function #4097

@NicoVogel

Description

@NicoVogel

Describe the bug

When executing the tests, each test fails because of TypeError: __vi_esm_0__.default is not a function.
After reducing it to the minimal reproducible example, I could isolate that the issue is the package pino.

You can find "working" tests here src/browser/working.spec.ts

The mocking does not work, but this is besides this bug

But the same code that uses pino is not able to load it: src/browser/logger.spec.ts

Reproduction

  1. git clone https://github.com/NicoVogel/logger-wrapper
  2. git checkout bug/vitest-browser-vi-esm-0-default-not-a-function
  3. (optional) reopen in dev container
  4. pnpm install
  5. cd packages/logger
  6. pnpm exec vitest -c vitest.browser.ts

System Info

System:
    OS: Linux 6.2 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (16) x64 13th Gen Intel(R) Core(TM) i5-1340P
    Memory: 24.36 GB / 31.05 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
    pnpm: 8.6.12 - ~/.nvm/versions/node/v18.17.1/bin/pnpm
  Browsers:
    Chrome: 116.0.5845.140
  npmPackages:
    @vitest/browser: ^0.34.1 => 0.34.1

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: browserIssues and PRs related to the browser runnerp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions