From 58a60d979771fd4722349bf42f7545a1eb00a463 Mon Sep 17 00:00:00 2001 From: Sam Heavner Date: Fri, 9 Feb 2024 16:06:57 -0700 Subject: [PATCH 1/2] Fix SGNode test generation - `this.createNodeFile` was called only if `isGlobalMethodMockingEnabled` and `isGlobalMethodMockingEfficientMode`, moved outside the case so it always runs. --- bsc-plugin/src/lib/rooibos/RooibosSession.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bsc-plugin/src/lib/rooibos/RooibosSession.ts b/bsc-plugin/src/lib/rooibos/RooibosSession.ts index adb07734..8cc5c2ba 100644 --- a/bsc-plugin/src/lib/rooibos/RooibosSession.ts +++ b/bsc-plugin/src/lib/rooibos/RooibosSession.ts @@ -45,15 +45,17 @@ export class RooibosSession { console.log('Efficient global stubbing is enabled'); this.namespaceLookup = this.getNamespaces(program); for (let testSuite of this.sessionInfo.testSuitesToRun) { - if (testSuite.isNodeTest) { - this.createNodeFile(program, testSuite); - } mockUtil.gatherGlobalMethodMocks(testSuite); } } else { this.namespaceLookup = new Map(); } + for (let testSuite of this.sessionInfo.testSuitesToRun) { + if (testSuite.isNodeTest) { + this.createNodeFile(program, testSuite); + } + } } updateSessionStats() { From e50f5f20d71b155899ba624505f19df6c9e985d0 Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Fri, 9 Feb 2024 20:00:52 -0400 Subject: [PATCH 2/2] Update RooibosSession.ts --- bsc-plugin/src/lib/rooibos/RooibosSession.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bsc-plugin/src/lib/rooibos/RooibosSession.ts b/bsc-plugin/src/lib/rooibos/RooibosSession.ts index 8cc5c2ba..e1f31017 100644 --- a/bsc-plugin/src/lib/rooibos/RooibosSession.ts +++ b/bsc-plugin/src/lib/rooibos/RooibosSession.ts @@ -41,6 +41,15 @@ export class RooibosSession { prepareForTranspile(editor: AstEditor, program: Program, mockUtil: MockUtil) { this.addTestRunnerMetadata(editor); this.addLaunchHookToExistingMain(editor); + + // Make sure to create the node files before running the global mock logic + // We realy on them in order to check the component scope for the global functions + for (let testSuite of this.sessionInfo.testSuitesToRun) { + if (testSuite.isNodeTest) { + this.createNodeFile(program, testSuite); + } + } + if (this.config.isGlobalMethodMockingEnabled && this.config.isGlobalMethodMockingEfficientMode) { console.log('Efficient global stubbing is enabled'); this.namespaceLookup = this.getNamespaces(program); @@ -51,11 +60,6 @@ export class RooibosSession { } else { this.namespaceLookup = new Map(); } - for (let testSuite of this.sessionInfo.testSuitesToRun) { - if (testSuite.isNodeTest) { - this.createNodeFile(program, testSuite); - } - } } updateSessionStats() {