Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unified Recorder] TestProxyClient takes test context to generate recordings at desired location #17388

Merged
merged 55 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e13ec0d
TestProxyClient takes test context to generate recordings at desired …
HarshaNalluru Aug 31, 2021
40c4a5a
set /workspaces/azure-sdk-for-js/ as entry point
HarshaNalluru Sep 20, 2021
30058f7
use Test as testContext type
HarshaNalluru Sep 20, 2021
5a2509e
update recorder-new tests
HarshaNalluru Sep 20, 2021
70e1bbb
update tests with before and after each
HarshaNalluru Sep 21, 2021
6eb87d1
relativePathCalculator - for browser => done
HarshaNalluru Sep 21, 2021
ccbd14c
create utils folder
HarshaNalluru Sep 21, 2021
47bb18a
export relativeRecordingsPathForBrowser to use in karma.conf
HarshaNalluru Sep 21, 2021
05c00b0
utils folder updates
HarshaNalluru Sep 21, 2021
1968f07
RECORDINGS_RELATIVE_PATH env variable in karma.conf
HarshaNalluru Sep 21, 2021
e950683
node side draft
HarshaNalluru Sep 21, 2021
6cb397c
relativeRecordingsPathForNode
HarshaNalluru Sep 27, 2021
f927df5
findRecordingsFolderPath
HarshaNalluru Sep 27, 2021
25fa7a6
remove console.logs
HarshaNalluru Sep 27, 2021
390cb3f
Update sdk/test-utils/recorder-new/README.md
HarshaNalluru Sep 27, 2021
79c90da
throw new Error(
HarshaNalluru Sep 27, 2021
d3bd3e0
Merge branch 'harshan/recorder/issue/17384' of https://github.com/har…
HarshaNalluru Sep 27, 2021
1475dc2
Update sdk/test-utils/recorder-new/README.md
HarshaNalluru Sep 27, 2021
b49b78e
lock file
HarshaNalluru Sep 27, 2021
5030832
--net=host docs
HarshaNalluru Sep 27, 2021
eeb79cc
sample recordings
HarshaNalluru Sep 27, 2021
b71afda
refactor existing tests
HarshaNalluru Sep 27, 2021
3ce602d
server and tests hitting the server
HarshaNalluru Sep 27, 2021
75e96c2
Merge branch 'harshan/recorder/issue/17384' of https://github.com/har…
HarshaNalluru Sep 27, 2021
c916456
unrelated changes in package.json
HarshaNalluru Sep 27, 2021
fa2e266
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Sep 27, 2021
e110ccf
changelog
HarshaNalluru Sep 27, 2021
a66b3fb
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Sep 27, 2021
344ac2e
lock file
HarshaNalluru Sep 27, 2021
1c9f090
Jeremy's feedbackl
HarshaNalluru Sep 28, 2021
cc4420a
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Sep 30, 2021
3703d8e
lock file
HarshaNalluru Sep 30, 2021
56fa188
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Oct 1, 2021
51cbab0
lock file
HarshaNalluru Oct 1, 2021
91d46ad
Update sdk/test-utils/recorder-new/README.md
HarshaNalluru Oct 1, 2021
28037ec
Update sdk/test-utils/recorder-new/README.md
HarshaNalluru Oct 1, 2021
b863c43
readme
HarshaNalluru Oct 1, 2021
98b8def
Merge branch 'harshan/recorder/issue/17384' of https://github.com/har…
HarshaNalluru Oct 1, 2021
9b2db94
removing the exclamations. 🙂
HarshaNalluru Oct 1, 2021
dace442
address feedback
HarshaNalluru Oct 1, 2021
4f06aff
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Oct 1, 2021
da830bc
clientHttpClient
HarshaNalluru Oct 1, 2021
613f803
sample recordings
HarshaNalluru Oct 2, 2021
9ab9e1b
relativeRecordingsPathForBrowser -> relativeRecordingsPath
HarshaNalluru Oct 2, 2021
c5855cd
massive update to relativeRecordingsPath - which works fine on linux
HarshaNalluru Oct 2, 2021
5fe22e1
RECORDINGS_RELATIVE_PATH in karma.conf
HarshaNalluru Oct 2, 2021
b743285
dist-esm/test/index.spec.js doesn't exist
HarshaNalluru Oct 2, 2021
e942956
lock file
HarshaNalluru Oct 2, 2021
c08f8b1
updates for windows
HarshaNalluru Oct 2, 2021
b1d079c
`--add-host host.docker.internal:host-gateway`
HarshaNalluru Oct 4, 2021
6239815
more comments
HarshaNalluru Oct 4, 2021
e6c6b0a
remove unintended file
HarshaNalluru Oct 4, 2021
912568b
Update sdk/test-utils/recorder-new/CHANGELOG.md
HarshaNalluru Oct 4, 2021
a110c8f
remove sq brackets
HarshaNalluru Oct 4, 2021
53b24cb
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Oct 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,870 changes: 1,068 additions & 802 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions sdk/test-utils/recorder-new/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Release History

## 1.0.0 (Unreleased)

## 2021-09-27

- TestProxyClient takes test context to generate recordings at desired location. [#17388](https://github.com/Azure/azure-sdk-for-js/pull/17388)
HarshaNalluru marked this conversation as resolved.
Show resolved Hide resolved
- Adds a server for the tests, to play the role of an actual service to be able to test the proxy-tool end-to-end.
[#17388](https://github.com/Azure/azure-sdk-for-js/pull/17388)

## 2021-07-17

- Building the unified recorder prototype leveraging the proxy-tool, works for both core-v1 and core-v2 SDKs. Shows data-tables and storage-queue as examples for core-v2 and core-v1 respectively.
[#15826](https://github.com/Azure/azure-sdk-for-js/pull/15826)
6 changes: 5 additions & 1 deletion sdk/test-utils/recorder-new/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ Feature work is being tracked at [#15829](https://github.com/Azure/azure-sdk-for

Run this command

> `docker run -v temp-location:/etc/testproxy -p 5001:5001 -p 5000:5000 azsdkengsys.azurecr.io/engsys/testproxy-lin:latest`
> `docker run -v /workspaces/azure-sdk-for-js/:/etc/testproxy -p 5001:5001 -p 5000:5000 azsdkengsys.azurecr.io/engsys/testproxy-lin:latest`
HarshaNalluru marked this conversation as resolved.
Show resolved Hide resolved

[Provide the root of the repo for the volume mapping for the accurate location while generating recordings.]
HarshaNalluru marked this conversation as resolved.
Show resolved Hide resolved

(Eventually, recorder will trigger this for you!)

[Note: Update `temp-location` in the command to your desired location.]

Add `--net=host` to let the Docker container access the localhost on host network.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Add `--net=host` to let the Docker container access the localhost on host network.
Add `--net=host` to disable network sandboxing and let the test proxy container access the host's network (for example, to access `localhost`).

This is considered a privileged mode of operation for linux containers, so it should be clear that this disables network namespacing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--net=host doesn't work on windows.
Switching to host.docker.internal which works on windows and mac(to access host's network) by default and by adding the host in linux with --add-host host.docker.internal:host-gateway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment is more about making it clear what --net=host does from a computer privileges standpoint. The sentence mentioned --net=host before, so I just think that if you mention to use it it should also mention that this disables the network namespace entirely and lets the container freely talk to everything on your network.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I did apply your suggestion. :)
But upon more testing, realized that whatever I wrote here didn't work on Windows and had to look for different ways.


If the above command doesn't work directly, try [Troubleshooting Access to Public Container Registry](https://github.com/Azure/azure-sdk-tools/tree/main/tools/test-proxy/docker#troubleshooting-access-to-public-container-registry).

Reference: [Using Test Proxy with docker container](https://github.com/Azure/azure-sdk-tools/tree/main/tools/test-proxy/docker#build-and-run)
Expand Down
23 changes: 18 additions & 5 deletions sdk/test-utils/recorder-new/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"main": "dist/index.js",
"module": "dist-esm/src/index.js",
"types": "./types/src/index.d.ts",
"browser": {
"./dist-esm/src/utils/relativePathCalculator.js": "./dist-esm/src/utils/relativePathCalculator.browser.js",
"./dist-esm/test/utils/server.js": "./dist-esm/test/utils/server.browser.js"
},
"scripts": {
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build:browser": "echo skipped",
Expand All @@ -17,14 +21,17 @@
"clean": "rimraf dist dist-esm test-dist typings *.tgz *.log",
"extract-api": "echo skipped",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "karma start --single-run",
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace dist-esm/test/*.spec.js dist-esm/test/node/*.spec.js",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"tests:server": "TS_NODE_COMPILER_OPTIONS=\"{\\\"module\\\": \\\"commonjs\\\"}\" ts-node test/utils/server.ts",
"temp-integration-test:browser": "concurrently \"npm run tests:server\" \"karma start --single-run\" --kill-others --success first",
"temp-integration-test:node": "concurrently \"npm run tests:server\" \"nyc mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace 'test/*.spec.ts'\" --kill-others --success first",
"lint:fix": "eslint package.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint package.json src test --ext .ts -f html -o recorder-lintReport.html || exit 0",
"pack": "npm pack 2>&1",
"unit-test:browser": "karma start --single-run",
"unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/*.spec.ts\"",
"unit-test:browser": "echo skipped",
"unit-test:node": "echo skipped",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser",
"test:node": "npm run clean && npm run build:test && npm run unit-test:node",
Expand Down Expand Up @@ -59,15 +66,18 @@
"dependencies": {
"@azure-tools/test-recorder": "^1.0.0",
"@azure/core-http": "^2.0.0",
"@azure/core-rest-pipeline": "^1.1.0"
"@azure/core-rest-pipeline": "^1.1.0",
"@azure/test-utils": "^1.0.0"
},
"devDependencies": {
"@azure/core-client": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@rollup/plugin-commonjs": "11.0.2",
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/express": "^4.16.0",
"@types/fs-extra": "^8.0.0",
"@types/chai": "^4.1.6",
"@types/md5": "^2.2.0",
Expand All @@ -77,8 +87,10 @@
"@types/mock-require": "~2.0.0",
"@types/mock-fs": "~4.10.0",
"chai": "^4.2.0",
"concurrently": "^6.2.1",
"dotenv": "^8.2.0",
"eslint": "^7.15.0",
"express": "^4.16.3",
"karma": "^6.2.0",
"karma-chrome-launcher": "^3.0.0",
"karma-coverage": "^2.0.0",
Expand Down Expand Up @@ -106,6 +118,7 @@
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-visualizer": "^4.0.4",
"tslib": "^2.2.0",
"ts-node": "^9.0.0",
"typescript": "~4.2.0",
"xhr-mock": "^2.4.1"
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions sdk/test-utils/recorder-new/src/core-v1-recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { HttpClient, HttpOperationResponse } from "@azure/core-http";
import { DefaultHttpClient, WebResourceLike } from "@azure/core-http";
import { isPlaybackMode, isRecordMode } from "@azure-tools/test-recorder";
import { TestProxyHttpClient } from "./core-v2-recorder";
import { Test } from "mocha";

/**
* This client manages the recorder life cycle and interacts with the proxy-tool to do the recording,
Expand All @@ -15,8 +16,8 @@ import { TestProxyHttpClient } from "./core-v2-recorder";
*/
export class TestProxyHttpClientCoreV1 extends TestProxyHttpClient {
public httpClientCoreV1: HttpClient;
constructor(sessionFile: string) {
super(sessionFile);
constructor(testContext?: Test) {
super(testContext);
this.httpClientCoreV1 = new DefaultHttpClient();
}

Expand Down
29 changes: 20 additions & 9 deletions sdk/test-utils/recorder-new/src/core-v2-recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import {
SendRequest
} from "@azure/core-rest-pipeline";
import { env, isPlaybackMode, isRecordMode } from "@azure-tools/test-recorder";
import { RecorderError, RecordingStateManager } from "./utils";
import { RecorderError, RecordingStateManager } from "./utils/utils";
import { Test } from "mocha";
import { sessionFilePath } from "./utils/sessionFilePath";

const paths = {
playback: "/playback",
Expand All @@ -31,16 +33,25 @@ const paths = {
export class TestProxyHttpClient {
private url = "http://localhost:5000";
public recordingId?: string;
public mode: string;
public httpClient: HttpClient;
public mode!: string;
HarshaNalluru marked this conversation as resolved.
Show resolved Hide resolved
public httpClient!: HttpClient;
private stateManager = new RecordingStateManager();
private playback: boolean;
private playback!: boolean;
private sessionFile!: string;

constructor(private sessionFile: string) {
this.sessionFile = sessionFile;
this.mode = env.TEST_MODE;
this.playback = isPlaybackMode();
this.httpClient = createDefaultHttpClient();
constructor(private testContext?: Test | undefined) {
if (isRecordMode() || isPlaybackMode()) {
if (!this.testContext) {
HarshaNalluru marked this conversation as resolved.
Show resolved Hide resolved
throw new Error(
"Unable to determine the recording file path, testContext provided is not defined."
);
} else {
this.sessionFile = sessionFilePath(this.testContext);
this.mode = env.TEST_MODE;
this.playback = isPlaybackMode();
this.httpClient = createDefaultHttpClient();
}
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions sdk/test-utils/recorder-new/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

export { recorderHttpPolicy, TestProxyHttpClient } from "./core-v2-recorder";
export { TestProxyHttpClientCoreV1 } from "./core-v1-recorder";
export { relativeRecordingsPathForBrowser } from "./utils/relativePathCalculator";
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export function relativeRecordingsPathForNode() {
throw new Error("Attempted to use the function meant for node in a browser.");
}

export function relativeRecordingsPathForBrowser() {
// If you get this error, it's because you tried to use this config in a browser.
// It is meant to be imported in the karma configuration file and used to configure
// the browser launch specifications, not to be used within the browser itself.
throw new Error("Attempted to use the base karma configuration in a browser.");
}
96 changes: 96 additions & 0 deletions sdk/test-utils/recorder-new/src/utils/relativePathCalculator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import path from "path";
import fs from "fs";
import { RecorderError } from "./utils";

sadasant marked this conversation as resolved.
Show resolved Hide resolved
export function relativeRecordingsPathForNode(testContext: Mocha.Test) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a builtin called path.relative that may replace this function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, applied

const testAbsolutePath = testContext.file;
if (!testAbsolutePath) {
throw new RecorderError("Unable to grab the file path from the test run");
}

const recordingsPath = findRecordingsFolderPath(testAbsolutePath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this can be replaced with something like testAbsolutePath.split(path.sep) and then looking through the resulting array by index.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

const recordingsFolder = path.basename(recordingsPath);
const projectFolder = path.basename(path.resolve(recordingsPath, ".."));
const serviceFolder = path.basename(path.resolve(recordingsPath, "..", ".."));
const sdk = path.basename(path.resolve(recordingsPath, "..", "..", ".."));
sadasant marked this conversation as resolved.
Show resolved Hide resolved
if (sdk !== "sdk") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check seems redundant, if it's not "sdk" the findRecordingsFolderPath() would have failed already?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

throw new Error("Unexpected location for recordings, please fix the location.");
}
return path
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does path.join(...args).join(path.sep) produce anything other than args?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.join(...args).join(path.sep)

Double join?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that, meant path.join(...args).split(path.sep);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the args

.join(sdk, serviceFolder, projectFolder, recordingsFolder)
.split(path.sep)
.join(path.posix.sep);
}

sadasant marked this conversation as resolved.
Show resolved Hide resolved
export function relativeRecordingsPathForBrowser() {
const pathFormatted = process.cwd();
const projectFolder = path.basename(pathFormatted);
const serviceFolder = path.basename(path.resolve(pathFormatted, ".."));
const sdk = path.basename(path.resolve(pathFormatted, "..", ".."));
if (sdk !== "sdk") {
throw new Error("Unexpected location for recordings, please fix the location.");
}
return path
.join(sdk, serviceFolder, projectFolder, "recordings")
.split(path.sep)
.join(path.posix.sep);
}

/**
* ONLY WORKS IN THE NODE.JS ENVIRONMENT
*
* 1. Takes the test filePath as argument.
* 2. Looks for the potential `recordings` folder in its hierarchical path.
* 3. Returns the full path of the `recordings` folder
*
* While running the tests, `filePath` can vary depending on location of the test files, examples below
*
* 1. If roll-up generated bundle files are being leveraged to run the tests
* filePath = `<base path>\azure-sdk-for-js\sdk\storage\storage-blob\dist-test\index.node.js`
* 2. If ts complied dist-esm files are being used to run the tests
* filePath = `<base path>\azure-sdk-for-js\sdk\storage\storage-blob\dist-esm\test\utils.spec.js`
* filePath = `<base path>\azure-sdk-for-js\sdk\storage\storage-blob\dist-esm\test\node\utils.spec.js`
* 3. If `.spec.ts` test files are being used directly
* filePath = `<base path>\azure-sdk-for-js\sdk\storage\storage-blob\test\utils.spec.ts`
* filePath = `<base path>\azure-sdk-for-js\sdk\storage\storage-blob\test\node\utils.spec.ts`
* In the above examples, no matter where the test files are,
* the recordings are located at `<base path>\azure-sdk-for-js\sdk\storage\storage-blob\recordings\`.
* In order to playback the tests, exact location of the recordings is to be found,
* this is done by checking the parent(s) folders until the `recordings` folder is found.
*
* @export
* @param {string} filePath
* @returns {string} location of the `recordings` folder
*/
function findRecordingsFolderPath(filePath: string): string {
// Stripping away the file name
let currentPath = path.resolve(filePath, "..");
// File/folder path of a closest child of `currentPath` in the folder hierarchy of `filePath`
let lastPath = filePath;
try {
// While loop to find the entry point of the SDK
while (
!(
fs.existsSync(path.resolve(currentPath, "package.json")) &&
fs.existsSync(path.resolve(currentPath, "..", "..", "..", "sdk/")) &&
fs.existsSync(path.resolve(currentPath, "..", "..", "..", "rush.json"))
)
) {
lastPath = currentPath;
currentPath = path.resolve(currentPath, "..");
if (lastPath === currentPath) {
throw new Error(
`'package.json' is not found at ${currentPath} (reached the root directory)`
);
}
}
return path.resolve(currentPath, "recordings/");
HarshaNalluru marked this conversation as resolved.
Show resolved Hide resolved
} catch (error) {
throw new Error(
`Unable to locate the 'recordings' folder anywhere in the hierarchy of the file path ${filePath}\n ${error}`
);
}
}
28 changes: 28 additions & 0 deletions sdk/test-utils/recorder-new/src/utils/sessionFilePath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { env, generateTestRecordingFilePath } from "@azure-tools/test-recorder";
import { isNode } from "@azure/test-utils";
import { relativeRecordingsPathForNode } from "./relativePathCalculator";

export function sessionFilePath(testContext: Mocha.Test) {
if (!isNode) {
jeremymeng marked this conversation as resolved.
Show resolved Hide resolved
return `${env.RECORDINGS_RELATIVE_PATH}/${recordingFilePath(testContext)}`;
} else {
return `${relativeRecordingsPathForNode(testContext)}/${recordingFilePath(testContext)}`;
}
}

/**
* Generates a file path with the following structure:
*
* `{node|browsers}/<describe-block-title>/recording_<test-title>.json`
*/
export function recordingFilePath(testContext: Mocha.Test) {
return `${generateTestRecordingFilePath(
isNode ? "node" : "browsers",
testContext.parent!.fullTitle(),
testContext.title!,
"json"
)}`;
HarshaNalluru marked this conversation as resolved.
Show resolved Hide resolved
}
Loading