Skip to content

"Test attachment requires body or path to be set. Both are missing." when specifying an empty string for body #8630

@Codesleuth

Description

@Codesleuth

Describe the bug

Specifying body: "" when using annotations reports an error. However, this is a valid case (should annotate an empty string).
This appears to be caused by the simple if (!attachment.body ...) line here:

if (!attachment.body && !attachment.path) {

This would be better replaced with:

      if (attachment.body == null && !attachment.path) {
        throw new TypeError(`Test attachment requires body or path to be set. Both are missing.`)
      }

Reproduction

await annotate("Anything", { body: "" })

System Info

System:
    OS: macOS 15.6
    CPU: (10) arm64 Apple M1 Pro
    Memory: 199.09 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.19.0 - ~/.asdf/installs/nodejs/22.19.0/bin/node
    Yarn: 1.22.22 - ~/.asdf/installs/nodejs/22.19.0/bin/yarn
    npm: 10.9.3 - ~/.asdf/installs/nodejs/22.19.0/bin/npm
  Browsers:
    Chrome: 140.0.7339.213
    Edge: 140.0.3485.81
    Safari: 18.6

Used Package Manager

yarn

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions