summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDebadree Chatterjee <debadree333@gmail.com>2022-12-02 11:59:48 +0530
committerDanielle Adams <adamzdanielle@gmail.com>2023-01-04 20:31:49 -0500
commitbf6fbe2c494f92d719305bee6b28672e8eab2b72 (patch)
treea9721206d2d70bdd6c6d3acafc7ded48b11da5cf
parenta327a7874a4f7b4ca0d8a8369531e44606cb187c (diff)
downloadnode-new-bf6fbe2c494f92d719305bee6b28672e8eab2b72.tar.gz
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 <moshe@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
-rw-r--r--lib/internal/test_runner/test.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js
index 9372cb7032..c56c03c072 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() {