Skip to content

Commit 5cace9f

Browse files
authored
[recorder] Throw error if RECORDINGS_RELATIVE_PATH not set in browser (Azure#23057)
1 parent 20e1234 commit 5cace9f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

sdk/test-utils/recorder/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
### Other Changes
2222

2323
- Improved formatting of error messages returned by the test proxy. [#21575](https://github.com/Azure/azure-sdk-for-js/pull/21575)
24+
- An error is now thrown if the RECORDINGS_RELATIVE_PATH is not set in browser mode. [#23057](https://github.com/Azure/azure-sdk-for-js/pull/23057)
2425

2526
## 2.0.0 (2022-04-11)
2627

sdk/test-utils/recorder/src/utils/sessionFilePath.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ import { relativeRecordingsPath } from "./relativePathCalculator";
88
import { RecorderError } from "./utils";
99

1010
export function sessionFilePath(testContext: Mocha.Test): string {
11-
const recordingsFolder = !isNode ? env.RECORDINGS_RELATIVE_PATH : relativeRecordingsPath(); // sdk/service/project/recordings
11+
let recordingsFolder: string;
12+
if (isNode) {
13+
recordingsFolder = relativeRecordingsPath(); // sdk/service/project/recordings
14+
} else if (env.RECORDINGS_RELATIVE_PATH) {
15+
recordingsFolder = env.RECORDINGS_RELATIVE_PATH;
16+
} else {
17+
throw new RecorderError(
18+
"RECORDINGS_RELATIVE_PATH was not set while in browser mode. Ensure that process.env.RELATIVE_RECORDINGS_PATH has been set properly in your Karma configuration."
19+
);
20+
}
21+
1222
return `${recordingsFolder}/${recordingFilePath(testContext)}`;
1323
// sdk/service/project/recordings/{node|browsers}/<describe-block-title>/recording_<test-title>.json
1424
}

0 commit comments

Comments
 (0)