From d3645b98cdca8bd84bb35735e73c93fb87359cdd Mon Sep 17 00:00:00 2001 From: Julien Ripouteau Date: Mon, 21 Jul 2025 02:28:39 +0200 Subject: [PATCH 1/2] feat: add getActiveTestOrFail --- index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.ts b/index.ts index d34c603..eec07ae 100644 --- a/index.ts +++ b/index.ts @@ -133,6 +133,14 @@ export function getActiveTest() { return activeTest } +/** + * Get the test of currently running test or throw an error + */ +export function getActiveTestOrFail() { + if (!activeTest) throw new Error('Cannot access active test outside of a test callback') + return activeTest +} + /** * Make Japa process command line arguments. Later the parsed output * will be used by Japa to compute the configuration From 4bcb2a9b24cebb31564fae323a5ccc28fe8946ed Mon Sep 17 00:00:00 2001 From: Julien Ripouteau Date: Mon, 21 Jul 2025 02:31:45 +0200 Subject: [PATCH 2/2] style: fix not-related lint error --- index.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/index.ts b/index.ts index eec07ae..5d44ce3 100644 --- a/index.ts +++ b/index.ts @@ -89,12 +89,7 @@ export function test(title: string, callback?: TestExecutor void): Group { validator.ensureIsInPlanningPhase(executionPlanState.phase) - const group = createTestGroup( - title, - emitter, - runnerConfig!.refiner, - executionPlanState - ) + const group = createTestGroup(title, emitter, runnerConfig!.refiner, executionPlanState) executionPlanState.group = group /**