Skip to main content

method Deno.DenoTest.sanitizer

#DenoTest.sanitizer(options: { ops?: boolean; resources?: boolean; }): void

Configure sanitizers at the module level. This overrides CLI flags and config file settings, but can still be overridden per-test via sanitizeOps / sanitizeResources in test options.

Should be called at the top of the module, before any Deno.test() registrations — each call sets the defaults that subsequently registered tests inherit, so tests registered before the call use the previous defaults.

// Enable both sanitizers for all tests in this file
Deno.test.sanitizer({ ops: true, resources: true });

Deno.test("my test", () => {
  // This test will have ops and resources sanitizers enabled
});

Deno.test({
  name: "override per-test",
  sanitizeOps: false,
  fn() {
    // This test opts out of ops sanitizer
  },
});

Parameters #

#options: { ops?: boolean; resources?: boolean; }

Return Type #

void

Did you find what you needed?

Privacy policy