| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 644e239 commit cf0edeb
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4268,6 +4268,45 @@ added: | |||
| 4268 | 4268 | ||
| 4269 | 4269 | Can be used to abort test subtasks when the test has been aborted. | |
| 4270 | 4270 | ||
| 4271 | + ### `context.passed` | ||
| 4272 | + | ||
| 4273 | + <!-- YAML | ||
| 4274 | + added: REPLACEME | ||
| 4275 | + --> | ||
| 4276 | + | ||
| 4277 | + * Type: {boolean} | ||
| 4278 | + | ||
| 4279 | + Indicates whether the suite and all of its subtests have passed. | ||
| 4280 | + | ||
| 4281 | + ### `context.attempt` | ||
| 4282 | + | ||
| 4283 | + <!-- YAML | ||
| 4284 | + added: REPLACEME | ||
| 4285 | + --> | ||
| 4286 | + | ||
| 4287 | + * Type: {number} | ||
| 4288 | + | ||
| 4289 | + The current attempt number of the suite. Used in conjunction with the | ||
| 4290 | + `--test-rerun-failures` option to determine the attempt number of the current | ||
| 4291 | + run. | ||
| 4292 | + | ||
| 4293 | + ### `context.diagnostic(message)` | ||
| 4294 | + | ||
| 4295 | + <!-- YAML | ||
| 4296 | + added: REPLACEME | ||
| 4297 | + --> | ||
| 4298 | + | ||
| 4299 | + * `message` {string} A diagnostic message to output. | ||
| 4300 | + | ||
| 4301 | + Output a diagnostic message. This is typically used for logging information | ||
| 4302 | + about the current suite or its tests. | ||
| 4303 | + | ||
| 4304 | + ```js | ||
| 4305 | + test.describe('my suite', (suite) => { | ||
| 4306 | + suite.diagnostic('Suite diagnostic message'); | ||
| 4307 | + }); | ||
| 4308 | + ``` | ||
| 4309 | + | ||
| 4271 | 4310 | [TAP]: https://testanything.org/ | |
| 4272 | 4311 | [`--experimental-test-coverage`]: cli.md#--experimental-test-coverage | |
| 4273 | 4312 | [`--experimental-test-module-mocks`]: cli.md#--experimental-test-module-mocks | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -494,6 +494,18 @@ class SuiteContext { | |||
| 494 | 494 | get fullName() { | |
| 495 | 495 | return getFullName(this.#suite); | |
| 496 | 496 | } | |
| 497 | + | ||
| 498 | + get passed() { | ||
| 499 | + return this.#suite.passed; | ||
| 500 | + } | ||
| 501 | + | ||
| 502 | + get attempt() { | ||
| 503 | + return this.#suite.attempt ?? 0; | ||
| 504 | + } | ||
| 505 | + | ||
| 506 | + diagnostic(message) { | ||
| 507 | + this.#suite.diagnostic(message); | ||
| 508 | + } | ||
| 497 | 509 | } | |
| 498 | 510 | ||
| 499 | 511 | function parseExpectFailure(expectFailure) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,11 @@ before(common.mustCall((t) => { | |||
| 9 | 9 | ||
| 10 | 10 | suite('suite', common.mustCall((t) => { | |
| 11 | 11 | assert.strictEqual(t.fullName, 'suite'); | |
| 12 | + // Test new SuiteContext properties | ||
| 13 | + assert.strictEqual(typeof t.passed, 'boolean'); | ||
| 14 | + assert.strictEqual(t.attempt, 0); | ||
| 15 | + // diagnostic() can be called to add diagnostic output | ||
| 16 | + t.diagnostic('Suite diagnostic message'); | ||
| 12 | 17 | ||
| 13 | 18 | test('test', (t) => { | |
| 14 | 19 | assert.strictEqual(t.fullName, 'suite > test'); | |
@@ -26,3 +31,18 @@ suite('suite', common.mustCall((t) => { | |||
| 26 | 31 | test((t) => { | |
| 27 | 32 | assert.strictEqual(t.fullName, '<anonymous>'); | |
| 28 | 33 | }); | |
| 34 | + | ||
| 35 | + // Test SuiteContext passed, attempt, and diagnostic properties | ||
| 36 | + suite('suite with context checks', common.mustCall((ctx) => { | ||
| 37 | + assert.strictEqual(ctx.fullName, 'suite with context checks'); | ||
| 38 | + assert.strictEqual(typeof ctx.passed, 'boolean'); | ||
| 39 | + assert.strictEqual(ctx.attempt, 0); | ||
| 40 | + // Verify diagnostic method is callable | ||
| 41 | + ctx.diagnostic('Test diagnostic message in suite'); | ||
| 42 | + | ||
| 43 | + test('child test', () => { | ||
| 44 | + // Verify properties are accessible in nested test | ||
| 45 | + assert.strictEqual(typeof ctx.passed, 'boolean'); | ||
| 46 | + assert.strictEqual(ctx.attempt, 0); | ||
| 47 | + }); | ||
| 48 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments