bennypB
Denoβ€’9mo agoβ€’
1 reply
bennyp

Using scopes in deno.json to mock modules for tests

Hello, I have something like this in my deno.json

  "imports": {
    "#css": "./src/css/documents.ts",
    "@std/assert": "jsr:@std/assert@1",
    "@std/collections": "jsr:@std/collections@^1.0.10",
    "@std/expect": "jsr:@std/expect@^1.0.15",
    "@std/io": "jsr:@std/io@^0.225.2",
    "@std/testing": "jsr:@std/testing@^1.0.11",
  },
  "scopes": {
    "./src/lsp/methods/textDocument/completion.test.ts": {
      "#css": "./test/css-mock.ts"
    }
  }


completion.test.ts imports completion.ts which imports #css.
I expect that when I run deno test -A, my mock module would be loaded, not the real one

instead the real one is loaded. Please advise how I can mock modules for testing.
Was this page helpful?