Skip to content

[🐞] vitest mocks (vi.fn()) cause lexical scope errors and might cause Qwik errors #6

Open
@ianlet

Description

@ianlet

Describe the bug

As seen in this example, eslint is not happy because the callbacks (vi.fn() mocks) are not serializable and cross a serialization boundary. In most cases, it doesn't prevent tests to be run, but issues can arise if Qwik actually needs to serialize the values.

Explore if there could be elegant workarounds or if we need to provide mocking functionalities written for Qwik.

Reproduction

https://github.com/ianlet/qwik-testing-library/blob/main/apps/qwik-basic-demo/src/components/qwik-component.spec.tsx#L223

Steps to reproduce

No response

System Info

System:
    OS: Linux 6.10 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
    Memory: 4.71 GB / 15.37 GB
    Container: Yes
    Shell: 3.7.1 - /usr/bin/fish
  Binaries:
    Node: 22.9.0 - ~/.asdf/installs/nodejs/22.9.0/bin/node
    Yarn: 1.22.19 - ~/.asdf/shims/yarn
    npm: 10.8.3 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 9.11.0 - ~/.asdf/installs/pnpm/9.11.0/bin/pnpm
  Browsers:
    Chromium: 129.0.6668.58

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions