From c647adbc868359b4be160b0b3168287b89a1c4ae Mon Sep 17 00:00:00 2001 From: Debadree Chatterjee Date: Fri, 2 Dec 2022 11:59:48 +0530 Subject: [PATCH] lib: added SuiteContext class added SuiteContext class to replace object literal Fixes: https://github.com/nodejs/node/issues/45641 Refs: https://github.com/nodejs/node/issues/45641#issuecomment-1329130581 PR-URL: https://github.com/nodejs/node/pull/45687 Reviewed-By: Moshe Atlow Reviewed-By: Colin Ihrig --- lib/internal/test_runner/test.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 9372cb7032ec21..c56c03c0725586 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -146,6 +146,22 @@ class TestContext { } } +class SuiteContext { + #suite; + + constructor(suite) { + this.#suite = suite; + } + + get signal() { + return this.#suite.signal; + } + + get name() { + return this.#suite.name; + } +} + class Test extends AsyncResource { #abortController; #outerSignal; @@ -737,7 +753,8 @@ class Suite extends Test { } getRunArgs() { - return { ctx: { signal: this.signal, name: this.name }, args: [] }; + const ctx = new SuiteContext(this); + return { ctx, args: [ctx] }; } async run() {