diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-09-06 14:17:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-06 14:17:33 +0200 |
commit | 147c845c95bfd55548d5b5b56d70f0a616410e0d (patch) | |
tree | 29b48080ebf971533b99423f8986b30269093efe /cli/js | |
parent | 9befa566ec3ef4594fd7ffb2cbdf5b34d9705e16 (diff) |
feat(test): Add Deno.test.ignore and Deno.test.only (#20365)
Closes https://github.com/denoland/deno/issues/17106
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/40_testing.js | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/cli/js/40_testing.js b/cli/js/40_testing.js index afa9a6552..44b360a59 100644 --- a/cli/js/40_testing.js +++ b/cli/js/40_testing.js @@ -600,11 +600,11 @@ let currentBenchUserExplicitStart = null; /** @type {number | null} */ let currentBenchUserExplicitEnd = null; -// Main test function provided by Deno. -function test( +function testInner( nameOrFnOrOptions, optionsOrFn, maybeFn, + overrides = {}, ) { if (typeof ops.op_register_test != "function") { return; @@ -690,6 +690,8 @@ function test( testDesc = { ...defaults, ...nameOrFnOrOptions, fn, name }; } + testDesc = { ...testDesc, ...overrides }; + // Delete this prop in case the user passed it. It's used to detect steps. delete testDesc.parent; const jsError = core.destructureError(new Error()); @@ -721,6 +723,27 @@ function test( }); } +// Main test function provided by Deno. +function test( + nameOrFnOrOptions, + optionsOrFn, + maybeFn, +) { + return testInner(nameOrFnOrOptions, optionsOrFn, maybeFn); +} + +test.ignore = function (nameOrFnOrOptions, optionsOrFn, maybeFn) { + return testInner(nameOrFnOrOptions, optionsOrFn, maybeFn, { ignore: true }); +}; + +test.only = function ( + nameOrFnOrOptions, + optionsOrFn, + maybeFn, +) { + return testInner(nameOrFnOrOptions, optionsOrFn, maybeFn, { only: true }); +}; + let registeredWarmupBench = false; // Main bench function provided by Deno. |