diff options
author | Yongwook Choi <hyperflow@kakao.com> | 2022-04-06 23:51:38 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-06 16:51:38 +0200 |
commit | 0df18542499d1220f1182496d3b7028eef243eb0 (patch) | |
tree | dbfb2fb6490371c45eadd9eabe0a8e81ea304fa1 /runtime/js | |
parent | e33329b47ea1586bd1fbc686cae3048a080039ca (diff) |
feat(test): Add "name", "origin" and "parent" to "Deno.TestContext" (#14007)
This commit adds following fields to "Deno.TestContext" interface:
- name
- origin
- parent
These are prerequisites for supporting snapshot functionality in
"std/testing".
Diffstat (limited to 'runtime/js')
-rw-r--r-- | runtime/js/40_testing.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js index abbef2ae4..0b75daa24 100644 --- a/runtime/js/40_testing.js +++ b/runtime/js/40_testing.js @@ -792,6 +792,7 @@ const step = new TestStep({ name: test.name, parent: undefined, + parentContext: undefined, rootTestDescription: description, sanitizeOps: test.sanitizeOps, sanitizeResources: test.sanitizeResources, @@ -1064,8 +1065,9 @@ * }} TestStepDefinition * * @typedef {{ - * name: string; + * name: string, * parent: TestStep | undefined, + * parentContext: TestContext | undefined, * rootTestDescription: { origin: string; name: string }; * sanitizeOps: boolean, * sanitizeResources: boolean, @@ -1099,6 +1101,10 @@ return this.#params.parent; } + get parentContext() { + return this.#params.parentContext; + } + get rootTestDescription() { return this.#params.rootTestDescription; } @@ -1269,6 +1275,18 @@ return { [SymbolToStringTag]: "TestContext", /** + * The current test name. + */ + name: parentStep.name, + /** + * Parent test context. + */ + parent: parentStep.parentContext ?? undefined, + /** + * File Uri of the test code. + */ + origin: parentStep.rootTestDescription.origin, + /** * @param nameOrTestDefinition {string | TestStepDefinition} * @param fn {(t: TestContext) => void | Promise<void>} */ @@ -1284,6 +1302,7 @@ const subStep = new TestStep({ name: definition.name, parent: parentStep, + parentContext: this, rootTestDescription: parentStep.rootTestDescription, sanitizeOps: getOrDefault( definition.sanitizeOps, |