summaryrefslogtreecommitdiff
path: root/runtime/js/40_testing.js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js/40_testing.js')
-rw-r--r--runtime/js/40_testing.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js
index 3850e411d..13cdcd32e 100644
--- a/runtime/js/40_testing.js
+++ b/runtime/js/40_testing.js
@@ -554,6 +554,7 @@
const tests = [];
/** @type {BenchDescription[]} */
const benchDescs = [];
+ let isTestOrBenchSubcommand = false;
// Main test function provided by Deno.
function test(
@@ -561,6 +562,10 @@
optionsOrFn,
maybeFn,
) {
+ if (!isTestOrBenchSubcommand) {
+ return;
+ }
+
let testDef;
const defaults = {
ignore: false,
@@ -669,6 +674,10 @@
optionsOrFn,
maybeFn,
) {
+ if (!isTestOrBenchSubcommand) {
+ return;
+ }
+
core.opSync("op_bench_check_unstable");
let benchDesc;
const defaults = {
@@ -1043,6 +1052,13 @@
return core.opSync("op_bench_now");
}
+ // This function is called by Rust side if we're in `deno test` or
+ // `deno bench` subcommand. If this function is not called then `Deno.test()`
+ // and `Deno.bench()` become noops.
+ function enableTestAndBench() {
+ isTestOrBenchSubcommand = true;
+ }
+
async function runTests({
filter = null,
shuffle = null,
@@ -1507,6 +1523,7 @@
window.__bootstrap.internals = {
...window.__bootstrap.internals ?? {},
+ enableTestAndBench,
runTests,
runBenchmarks,
};