Skip to content

Commit 3494d5e

Browse files
Merge master into feature/emr
2 parents 790a712 + cd85e10 commit 3494d5e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/core/src/testInteg/globalSetup.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import * as tokenProvider from '../auth/sso/ssoAccessTokenProvider'
1616
import * as testUtil from '../test/testUtil'
1717
import { DeviceFlowAuthorization } from '../auth/sso/ssoAccessTokenProvider'
1818
import { globals } from '../shared'
19+
import { GlobalState } from '../shared/globalState'
20+
import { FakeExtensionContext } from '../test/fakeExtensionContext'
1921

2022
// ASSUMPTION: Tests are not run concurrently
2123

@@ -48,6 +50,15 @@ export async function mochaGlobalSetup(extensionId: string) {
4850
if (getLogger() instanceof ToolkitLogger) {
4951
;(getLogger() as ToolkitLogger).logToConsole()
5052
}
53+
54+
const fakeContext = await FakeExtensionContext.create()
55+
const testFolder = await testUtil.TestFolder.create()
56+
fakeContext.globalStorageUri = vscode.Uri.parse(testFolder.pathFrom('.'))
57+
fakeContext.extensionPath = globals.context.extensionPath
58+
Object.assign(globals, {
59+
// eslint-disable-next-line aws-toolkits/no-banned-usages
60+
globalState: new GlobalState(fakeContext.globalState),
61+
})
5162
}
5263
}
5364

@@ -58,9 +69,12 @@ export async function mochaGlobalTeardown(this: Mocha.Context) {
5869
}
5970

6071
export const mochaHooks = {
61-
beforeEach(this: Mocha.Context) {
72+
async beforeEach(this: Mocha.Context) {
6273
globals.telemetry.clearRecords()
6374
globals.telemetry.logger.clear()
75+
76+
// mochaGlobalSetup() set this to a fake, so it's safe to clear it here.
77+
await globals.globalState.clear()
6478
},
6579
afterEach(this: Mocha.Context) {
6680
patchWindow()

0 commit comments

Comments
 (0)