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

[recorder] Support Vitest/Mocha both #28708

Closed
wants to merge 2 commits into from
Closed

Conversation

mpodwysocki
Copy link
Member

Packages impacted by this PR

  • @azure-tools/test-recorder

Issues associated with this PR

Describe the problem that is addressed by this PR

Migrates the @azure-tools/test-recorder to tshy and ESM to support both vitest and Mocha

What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen?

Are there test cases added in this PR? (If not, why?)

Provide a list of related PRs (if any)

Command used to generate this PR:**(Applicable only to SDK release request PRs)

Checklists

  • Added impacted package name to the issue description
  • Does this PR needs any fixes in the SDK Generator?** (If so, create an Issue in the Autorest/typescript repository and link it here)
  • Added a changelog (if necessary)

Copy link
Member

@maorleger maorleger left a comment

Choose a reason for hiding this comment

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

THANK YOU for starting this! I have a few comments but honestly they are not blocking. Will finish my review after my next meeting

@@ -54,19 +92,23 @@ export class Recorder {
private variables: Record<string, string>;
private matcherSet = false;

constructor(private testContext?: Test | undefined) {
constructor(private testContext?: TestInfo) {
if (!this.testContext) {
Copy link
Member

Choose a reason for hiding this comment

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

👍 much prefer this style of coding. Does that also allow us to remove the if (this.testContext) call in line 109 since we validated it exists already?

Also, previous code only threw if this.testContext is falsy and we're in recording / playback mode. So should this check also skip throwing if we're in live mode?


export function sessionFilePath(testContext: Mocha.Test): string {
export interface TestContext {
Copy link
Member

Choose a reason for hiding this comment

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

Should this live under testInfo ?

@@ -169,8 +170,8 @@ describe("TestProxyClient functions", () => {
await client.start({ envSetupForPlayback: {} });
throw new Error("should not have reached here, start() call should have failed");
} catch (error: any) {
expect((error as RecorderError).name).to.equal("RecorderError");
expect((error as RecorderError).message).to.equal(
assert.equal((error as RecorderError).name, "RecorderError");
Copy link
Member

Choose a reason for hiding this comment

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

total nitpicking, and feel free to ignore since it's also existing code, but I don't believe this error as RecorderError gives us anything here (it's an any today, and as conversions aren't checked). Would be nice to do a minor cosmetic cleanup while we're here

"compilerOptions": {
"outDir": "./dist-test/browser",
"rootDir": ".",
"skipLibCheck": true
Copy link
Member

Choose a reason for hiding this comment

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

Talk to me friendo, why do we need to skip lib check?

Copy link
Member Author

Choose a reason for hiding this comment

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

Until we fix the whole browser testing stuff, it's just this way for now.

@mpodwysocki
Copy link
Member Author

Closing in favor of #28667

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants