Skip to content

Commit 006991b

Browse files
authored
fix: stub sdk-test-helpers in browser environments (#132)
The "sdk-test-helpers" file contains helper functions that generated SDKs use in their generated unit tests. These functions are never actually needed when running standard operational code, therefore they are never used in the browser. The `expect` library that we use for testing has a dependency that isn't browser friendly in certain scenarios. This causes the core and any SDKs importing it to throw errors in these scenarios (like the React framework). This change stubs the sdk-test-helpers in browser environments the same way we stub the credentials file reading code.
1 parent 43074a9 commit 006991b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/sdk-test-helpers.browser.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Dummy for browser
2+
export function checkUrlAndMethod(options, url: string, method: any) {
3+
return;
4+
};
5+
6+
export function checkMediaHeaders(createRequestMock, accept: string, contentType: string) {
7+
return;
8+
};
9+
10+
export function checkUserHeader(createRequestMock, userHeaderName: string, userHeaderValue: string) {
11+
return;
12+
};
13+
14+
export function checkForSuccessfulExecution(createRequestMock) {
15+
return;
16+
};
17+
18+
export function getOptions(createRequestMock) {
19+
return;
20+
};
21+
22+
export function expectToBePromise(sdkPromise) {
23+
return;
24+
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
"tough-cookie": "^4.0.0"
7676
},
7777
"browser": {
78-
"./auth/utils/read-credentials-file": "./auth/utils/read-credentials-file.browser"
78+
"./auth/utils/read-credentials-file": "./auth/utils/read-credentials-file.browser",
79+
"./lib/sdk-test-helpers": "./lib/sdk-test-helpers.browser"
7980
},
8081
"engines": {
8182
"node": ">=10"

0 commit comments

Comments
 (0)