Snippets in VS Code test framework

Hi,

I’m trying to update my package to use the new VS Code test framework. In my runtest.jl file, I have:

@testsnippet MySnippet begin
    A = [1 2; 2 4]
end

@testitem "LinModel construction" setup=[MySnippet] begin
    @test A == [1 2; 2 4]
end

if I press on the play button here:
image
This error is printed in test results:

  Expression: A == [1 2; 2 4]
  UndefVarError: `A` not defined in `Main.var"##233"`
  Suggestion: check for spelling errors or missing imports.

I’m using the Julia Extension v.1.83.2 :

What I’m I missing ?

Your test runs fine on my system. Maybe try updating your packages and VSCode (I’m on 1.97.0).

sys info:

julia> versioninfo()
Julia Version 1.11.3
Commit d63adeda50 (2025-01-21 19:42 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 16 × 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, tigerlake)
Threads: 8 default, 0 interactive, 4 GC (on 16 virtual cores)
Environment:
  JULIA_EDITOR = code.cmd
  JULIA_NUM_THREADS = 8
1 Like

Thanks for the tips! I first tried to update the julia extension and it was always coming back to v1.83.2. I figured that it was an incompatibility with my VS Code version. And yes my VS Code version was old (june 2024). I updated my VS Code and everything worked after.

1 Like