Skip to content

Unhelpful error when executing malformed TestAction #3092

@timbrinded

Description

@timbrinded

Describe the bug

TypeErrors on vitest TestActions, e.g. beforeAll(), are unhelpful and merely state:

FAIL  test.spec.ts > first
TypeError: fn is not a function

In the simple error below, it can be easily seen that someone has entered a text label into beforeAll() (which is common as other test suites allow this).

We would expect vsc to flag this up - however this cannot be relied up in big projects as red squiggles can sometimes take a long time to appear. (common issue with typescript is slow performance of the language server).

It would help debugging usages of vitest if we bubbled up why functions weren't able to be transpiled and called.

Reproduction

Reproduction found here

System Info

System:
    OS: Linux 5.19 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
    CPU: (16) x64 Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz
    Memory: 18.45 GB / 46.85 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    Yarn: 3.2.0 - ~/.yarn/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
  Browsers:
    Brave Browser: 111.1.49.120
    Chrome: 111.0.5563.110
    Firefox: 111.0.1
  npmPackages:
    vitest: ^0.29.7 => 0.29.7

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions