Skip to content

Commit

Permalink
Update migration guide to remove XhrHttpClient (Azure#20364)
Browse files Browse the repository at this point in the history
* Update migration guide

* Spelling
  • Loading branch information
joheredi authored Feb 14, 2022
1 parent b6be7b0 commit a927a8b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions sdk/test-utils/recorder/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The new recorder is version 2.0.0 of the `@azure-tools/test-recorder` package. U
// ...
"devDependencies": {
// ...
"@azure-tools/test-credential" : "^1.0.0", // If you're using `@azure/identity` in your tests
"@azure-tools/test-credential": "^1.0.0", // If you're using `@azure/identity` in your tests
"@azure-tools/test-recorder": "^2.0.0"
}
}
Expand Down Expand Up @@ -122,6 +122,19 @@ await recorder.stop();

It is important that `recorder.stop()` is called, or otherwise the next test will throw an error when trying to start the already started recorder. Additionally, it is important that both the `start` and `stop` calls are awaited, for similar reasons.

## XHRHttpClient

The legacy recorder didn't support recording browser calls made through the Fetch API. As a result, when fetch API was introduced in `core-rest-pipeline` a workaround was applied to the libraries not yet migrated to the new recorder, this workaround needs to be removed as part of the migration. Make the following changes, typically located in `utils/recordedClient.ts`

```diff
- const httpClient = isNode || isLiveMode() ? undefined : createXhrHttpClient();
```

```diff
- recorder.configureClientOptions({ httpClient, ...options })
+ recorder.configureClientOptions(options)
```

## Environment variables

In the legacy recorder, the `replaceableVariables` option could be used to specify environment variables that would be replaced in the recording and set during playback. This could be used to ensure that secrets and user-specific options do not appear in the recording body.
Expand Down Expand Up @@ -283,7 +296,7 @@ const {

// reporters - to be removed
"json-to-file"

/* ... */
// jsonToFileReporter - to be removed
jsonToFileReporter: {
Expand All @@ -298,6 +311,7 @@ browserConsoleLogOptions: {
```

Remove the following "devDependencies" from `package.json`

```js
"karma-json-preprocessor": "^0.3.3",
"karma-json-to-file-reporter": "^1.0.1",
Expand Down

0 comments on commit a927a8b

Please sign in to comment.