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

add timeout config in vitestconfig and update recordedClient.ts template for esm package #2632

Merged
merged 5 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@
import { Context } from "mocha";
import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";

const envSetupForPlayback: Record<string, string> = {
ENDPOINT: "https://endpoint",
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
const replaceableVariables: Record<string, string> = {
SUBSCRIPTION_ID: "azure_subscription_id",
};

const recorderEnvSetup: RecorderStartOptions = {
envSetupForPlayback,
envSetupForPlayback: replaceableVariables,
};

/**
* creates the recorder and reads the environment variables from the `.env` file.
* Should be called first in the test suite to make sure environment variables are
* read before they are being used.
*/

export async function createRecorder(context: Context): Promise<Recorder> {
const recorder = new Recorder(context.currentTest);
await recorder.start(recorderEnvSetup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@
import { Context } from "mocha";
import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";

const envSetupForPlayback: Record<string, string> = {
ENDPOINT: "https://endpoint",
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
const replaceableVariables: Record<string, string> = {
SUBSCRIPTION_ID: "azure_subscription_id",
};

const recorderEnvSetup: RecorderStartOptions = {
envSetupForPlayback,
envSetupForPlayback: replaceableVariables,
};

/**
* creates the recorder and reads the environment variables from the `.env` file.
* Should be called first in the test suite to make sure environment variables are
* read before they are being used.
*/

export async function createRecorder(context: Context): Promise<Recorder> {
const recorder = new Recorder(context.currentTest);
await recorder.start(recorderEnvSetup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@
import { Context } from "mocha";
import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";

const envSetupForPlayback: Record<string, string> = {
ENDPOINT: "https://endpoint",
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
const replaceableVariables: Record<string, string> = {
SUBSCRIPTION_ID: "azure_subscription_id",
};

const recorderEnvSetup: RecorderStartOptions = {
envSetupForPlayback,
envSetupForPlayback: replaceableVariables,
};

/**
* creates the recorder and reads the environment variables from the `.env` file.
* Should be called first in the test suite to make sure environment variables are
* read before they are being used.
*/

export async function createRecorder(context: Context): Promise<Recorder> {
const recorder = new Recorder(context.currentTest);
await recorder.start(recorderEnvSetup);
Expand Down
6 changes: 4 additions & 2 deletions packages/rlc-common/src/metadata/buildVitestConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const nodeConfig = `export default defineConfig({
"provider": "istanbul",
"reporter": ["text", "json", "html"],
"reportsDirectory": "coverage"
}
},
testTimeout: 1200000,
}
});`;

Expand Down Expand Up @@ -68,7 +69,8 @@ export default defineConfig({
"provider": "istanbul",
"reporter": ["text", "json", "html"],
"reportsDirectory": "coverage-browser"
}
},
testTimeout: 1200000,
}
});`;

Expand Down
5 changes: 4 additions & 1 deletion packages/rlc-common/src/test/buildRecordedClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export function buildRecordedClientFile(model: RLCModel) {
});
return {
path: "test/public/utils/recordedClient.ts",
content: recordedClientFileContents({})
content: recordedClientFileContents({
isEsm: model.options?.moduleKind === "esm",
isCjs: model.options?.moduleKind === "cjs"
})
};
}
37 changes: 27 additions & 10 deletions packages/rlc-common/src/test/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,48 @@ module.exports = function (config) {
`;

export const recordedClientContent = `

{{#if isEsm}}
import {
Recorder,
RecorderStartOptions,
VitestTestContext,
} from "@azure-tools/test-recorder";
{{/if}}

{{#if isCjs}}
import { Context } from "mocha";
import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";
{{/if}}

const envSetupForPlayback: Record<string, string> = {
ENDPOINT: "https://endpoint",
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
const replaceableVariables: Record<string, string> = {
SUBSCRIPTION_ID: "azure_subscription_id"
};

const recorderEnvSetup: RecorderStartOptions = {
envSetupForPlayback
envSetupForPlayback: replaceableVariables,
};

/**
* creates the recorder and reads the environment variables from the \`.env\` file.
* Should be called first in the test suite to make sure environment variables are
* read before they are being used.
*/
* creates the recorder and reads the environment variables from the \`.env\` file.
* Should be called first in the test suite to make sure environment variables are
* read before they are being used.
*/
{{#if isEsm}}
export async function createRecorder(context: VitestTestContext): Promise<Recorder> {
const recorder = new Recorder(context);
await recorder.start(recorderEnvSetup);
return recorder;
}
{{/if}}

{{#if isCjs}}
export async function createRecorder(context: Context): Promise<Recorder> {
const recorder = new Recorder(context.currentTest);
await recorder.start(recorderEnvSetup);
return recorder;
}
{{/if}}
`;

export const sampleTestContent = `
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { Context } from "mocha";
import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";
import {
Recorder,
RecorderStartOptions,
VitestTestContext,
} from "@azure-tools/test-recorder";

const envSetupForPlayback: Record<string, string> = {
ENDPOINT: "https://endpoint",
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
const replaceableVariables: Record<string, string> = {
SUBSCRIPTION_ID: "azure_subscription_id",
};

const recorderEnvSetup: RecorderStartOptions = {
envSetupForPlayback,
envSetupForPlayback: replaceableVariables,
};

/**
* creates the recorder and reads the environment variables from the `.env` file.
* Should be called first in the test suite to make sure environment variables are
* read before they are being used.
*/
export async function createRecorder(context: Context): Promise<Recorder> {
const recorder = new Recorder(context.currentTest);
export async function createRecorder(
context: VitestTestContext,
): Promise<Recorder> {
const recorder = new Recorder(context);
await recorder.start(recorderEnvSetup);
return recorder;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export default defineConfig({
reporter: ["text", "json", "html"],
reportsDirectory: "coverage-browser",
},
testTimeout: 1200000,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export default defineConfig({
reporter: ["text", "json", "html"],
reportsDirectory: "coverage",
},
testTimeout: 1200000,
},
});
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { Context } from "mocha";
import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";
import {
Recorder,
RecorderStartOptions,
VitestTestContext,
} from "@azure-tools/test-recorder";

const envSetupForPlayback: Record<string, string> = {
ENDPOINT: "https://endpoint",
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
const replaceableVariables: Record<string, string> = {
SUBSCRIPTION_ID: "azure_subscription_id",
};

const recorderEnvSetup: RecorderStartOptions = {
envSetupForPlayback,
envSetupForPlayback: replaceableVariables,
};

/**
* creates the recorder and reads the environment variables from the `.env` file.
* Should be called first in the test suite to make sure environment variables are
* read before they are being used.
*/
export async function createRecorder(context: Context): Promise<Recorder> {
const recorder = new Recorder(context.currentTest);
export async function createRecorder(
context: VitestTestContext,
): Promise<Recorder> {
const recorder = new Recorder(context);
await recorder.start(recorderEnvSetup);
return recorder;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export default defineConfig({
reporter: ["text", "json", "html"],
reportsDirectory: "coverage-browser",
},
testTimeout: 1200000,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export default defineConfig({
reporter: ["text", "json", "html"],
reportsDirectory: "coverage",
},
testTimeout: 1200000,
},
});
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { Context } from "mocha";
import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";
import {
Recorder,
RecorderStartOptions,
VitestTestContext,
} from "@azure-tools/test-recorder";

const envSetupForPlayback: Record<string, string> = {
ENDPOINT: "https://endpoint",
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
const replaceableVariables: Record<string, string> = {
SUBSCRIPTION_ID: "azure_subscription_id",
};

const recorderEnvSetup: RecorderStartOptions = {
envSetupForPlayback,
envSetupForPlayback: replaceableVariables,
};

/**
* creates the recorder and reads the environment variables from the `.env` file.
* Should be called first in the test suite to make sure environment variables are
* read before they are being used.
*/
export async function createRecorder(context: Context): Promise<Recorder> {
const recorder = new Recorder(context.currentTest);
export async function createRecorder(
context: VitestTestContext,
): Promise<Recorder> {
const recorder = new Recorder(context);
await recorder.start(recorderEnvSetup);
return recorder;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export default defineConfig({
reporter: ["text", "json", "html"],
reportsDirectory: "coverage-browser",
},
testTimeout: 1200000,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export default defineConfig({
reporter: ["text", "json", "html"],
reportsDirectory: "coverage",
},
testTimeout: 1200000,
},
});
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { Context } from "mocha";
import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";
import {
Recorder,
RecorderStartOptions,
VitestTestContext,
} from "@azure-tools/test-recorder";

const envSetupForPlayback: Record<string, string> = {
ENDPOINT: "https://endpoint",
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
const replaceableVariables: Record<string, string> = {
SUBSCRIPTION_ID: "azure_subscription_id",
};

const recorderEnvSetup: RecorderStartOptions = {
envSetupForPlayback,
envSetupForPlayback: replaceableVariables,
};

/**
* creates the recorder and reads the environment variables from the `.env` file.
* Should be called first in the test suite to make sure environment variables are
* read before they are being used.
*/
export async function createRecorder(context: Context): Promise<Recorder> {
const recorder = new Recorder(context.currentTest);
export async function createRecorder(
context: VitestTestContext,
): Promise<Recorder> {
const recorder = new Recorder(context);
await recorder.start(recorderEnvSetup);
return recorder;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export default defineConfig({
reporter: ["text", "json", "html"],
reportsDirectory: "coverage-browser",
},
testTimeout: 1200000,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export default defineConfig({
reporter: ["text", "json", "html"],
reportsDirectory: "coverage",
},
testTimeout: 1200000,
},
});
Loading
Loading