Skip to content

How do you ignore assert.same from busted *spec.lua files? #7

@ColinKennedy

Description

@ColinKennedy

busted extends assert with extra functions such as assert.same, assert.equal, etc. These fail llscheck calls.

assert.same({ "foo" }, { "bar" })

Gets this error

file.lua:1:16-19: undefined-field: Undefined field `same`.

Busted also defines a number of functions such as describe, it, after_each, before_each, etc. To disable those, I use the following .luarc.json

{
    "Lua.diagnostics.libraryFiles": "Disable",
    "Lua.workspace.checkThirdParty": "Disable",
    "Lua.workspace.library": [
        "/home/runner/work/nvim-best-practices-plugin-template/nvim-best-practices-plugin-template/deps/neovim/runtime/lua",
        "/home/runner/work/nvim-best-practices-plugin-template/nvim-best-practices-plugin-template/deps/neodev.nvim/types/stable"
    ],
    "diagnostics.globals": [
        "after_each",
        "before_each",
        "describe",
        "it",
        "vim"
    ],
    "runtime.version": "LuaJIT",
    "workspace.checkThirdParty": "Disable"
}

This works for describe, it, after_each, before_each but not for assert.same, assert.equal, etc. Probably I'm guessing because Busted is extending Lua's built-in assert and it isn't a "new" function.

How should I go about ignoring issues for just these assert.* functions? I tried adding assert, assert.same, etc to the diagnostics.globals with no luck.

Ideally I'd like to avoid adding --- @diagnostic disable: undefined-field to all of my test files but that is what I've been doing to get around this issue so far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions