[communication] Migrate @azure-rest/communication-messages to ESM/vitest (#31773)

### Packages impacted by this PR

- @azure-rest/communication-messages

### Issues associated with this PR

- https://github.com/Azure/azure-sdk-for-js/issues/31338

### Describe the problem that is addressed by this PR

Migrates the @azure-rest/communication-messages package to ESM/vitest

### 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](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
This commit is contained in:
Matthew Podwysocki 2024-11-14 17:35:55 -05:00 коммит произвёл GitHub
Родитель a6b5a3614a
Коммит 909440a1c5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
20 изменённых файлов: 212 добавлений и 248 удалений

Просмотреть файл

@ -19278,7 +19278,7 @@ packages:
dev: false
file:projects/communication-messages.tgz:
resolution: {integrity: sha512-oEFJuO+RzX3gA86WxlnTcUnnFTSzQPzasiwupB6/pl+KjI80ZX9UAOKDb2qRW1v1Pu3Ch/YeFAprVg21znmOAQ==, tarball: file:projects/communication-messages.tgz}
resolution: {integrity: sha512-IcDGaDqJ1GhWIIajWNiyS4FUnZB3JEvDYXG7mopGzk4wgpUfOhVoVrJuz07pg3unKTn48Oqlm4EOWFmAm0wbag==, tarball: file:projects/communication-messages.tgz}
name: '@rush-temp/communication-messages'
version: 0.0.0
dependencies:
@ -19288,6 +19288,8 @@ packages:
'@types/chai': 4.3.20
'@types/mocha': 10.0.9
'@types/node': 18.19.64
'@vitest/browser': 2.1.5(@types/node@18.19.64)(playwright@1.48.2)(typescript@5.6.3)(vitest@2.1.5)
'@vitest/coverage-istanbul': 2.1.5(vitest@2.1.5)
autorest: 3.7.1
chai: 4.3.10
dotenv: 16.4.5
@ -19304,18 +19306,32 @@ packages:
karma-sourcemap-loader: 0.4.0
mocha: 10.8.2
nyc: 17.1.0
playwright: 1.48.2
source-map-support: 0.5.21
ts-node: 10.9.2(@types/node@18.19.64)(typescript@5.6.3)
tslib: 2.8.1
typescript: 5.6.3
vitest: 2.1.5(@types/node@18.19.64)(@vitest/browser@2.1.5)
transitivePeerDependencies:
- '@swc/core'
- '@swc/wasm'
- '@edge-runtime/vm'
- '@vitest/ui'
- bufferutil
- debug
- happy-dom
- jiti
- jsdom
- less
- lightningcss
- msw
- safaridriver
- sass
- sass-embedded
- stylus
- sugarss
- supports-color
- terser
- utf-8-validate
- vite
- webdriverio
dev: false
file:projects/communication-phone-numbers.tgz:

Просмотреть файл

@ -1,18 +1,31 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "./types/src/index.d.ts",
"docModel": { "enabled": true },
"apiReport": { "enabled": true, "reportFolder": "./review" },
"mainEntryPointFilePath": "dist/esm/index.d.ts",
"docModel": {
"enabled": true
},
"apiReport": {
"enabled": true,
"reportFolder": "./review"
},
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/communication-messages.d.ts"
"publicTrimmedFilePath": "dist/communication-messages.d.ts"
},
"messages": {
"tsdocMessageReporting": { "default": { "logLevel": "none" } },
"tsdocMessageReporting": {
"default": {
"logLevel": "none"
}
},
"extractorMessageReporting": {
"ae-missing-release-tag": { "logLevel": "none" },
"ae-unresolved-link": { "logLevel": "none" }
"ae-missing-release-tag": {
"logLevel": "none"
},
"ae-unresolved-link": {
"logLevel": "none"
}
}
}
}

Просмотреть файл

@ -1,134 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// https://github.com/karma-runner/karma-chrome-launcher
process.env.CHROME_BIN = require("puppeteer").executablePath();
require("dotenv").config();
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: "./",
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ["source-map-support", "mocha"],
plugins: [
"karma-mocha",
"karma-mocha-reporter",
"karma-chrome-launcher",
"karma-firefox-launcher",
"karma-env-preprocessor",
"karma-coverage",
"karma-sourcemap-loader",
"karma-junit-reporter",
"karma-source-map-support",
],
// list of files / patterns to load in the browser
files: [
"dist-test/index.browser.js",
{
pattern: "dist-test/index.browser.js.map",
type: "html",
included: false,
served: true,
},
],
// list of files / patterns to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"**/*.js": ["sourcemap", "env"],
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
// Preprocess source file to calculate code coverage, however this will make source file unreadable
// "dist-test/index.js": ["coverage"]
},
envPreprocessor: [
"TEST_MODE",
"AZURE_CLIENT_SECRET",
"AZURE_CLIENT_ID",
"AZURE_TENANT_ID",
"CHANNEL_ID",
"RECIPIENT_PHONE_NUMBER",
"COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING",
"RECORDINGS_RELATIVE_PATH",
],
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["mocha", "coverage", "junit"],
coverageReporter: {
// specify a common output directory
dir: "coverage-browser/",
reporters: [
{ type: "json", subdir: ".", file: "coverage.json" },
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
{ type: "html", subdir: "html" },
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" },
],
},
junitReporter: {
outputDir: "", // results will be saved as $outputDir/$browserName.xml
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
suite: "", // suite will become the package name attribute in xml testsuite element
useBrowserName: false, // add browser name to report and classes names
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
properties: {}, // key value pair of properties to add to the <properties> section of the report
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// --no-sandbox allows our tests to run in Linux without having to change the system.
// --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.
browsers: ["ChromeHeadlessNoSandbox"],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: "ChromeHeadless",
flags: ["--no-sandbox", "--disable-web-security"],
},
},
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: 1,
browserNoActivityTimeout: 60000000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
client: {
mocha: {
// change Karma's debug.html to the mocha web reporter
reporter: "html",
timeout: "600000",
},
},
});
};

Просмотреть файл

@ -13,31 +13,28 @@
"isomorphic"
],
"license": "MIT",
"main": "dist/index.js",
"module": "./dist-esm/src/index.js",
"types": "./types/communication-messages.d.ts",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/commonjs/index.d.ts",
"repository": "github:Azure/azure-sdk-for-js",
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
"files": [
"dist/",
"dist-esm/src/",
"types/communication-messages.d.ts",
"README.md",
"LICENSE",
"review/*"
"LICENSE"
],
"engines": {
"node": ">=18.0.0"
},
"scripts": {
"build": "npm run clean && tsc -p . && dev-tool run bundle && dev-tool run vendored mkdirp ./review && dev-tool run extract-api",
"build:browser": "tsc -p . && dev-tool run vendored cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:debug": "tsc -p . && dev-tool run bundle && dev-tool run extract-api",
"build:node": "tsc -p . && dev-tool run vendored cross-env ONLY_NODE=true rollup -c 2>&1",
"build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
"build:browser": "dev-tool run build-package && dev-tool run vendored cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:debug": "dev-tool run build-package && dev-tool run bundle && dev-tool run extract-api",
"build:node": "dev-tool run build-package && dev-tool run vendored cross-env ONLY_NODE=true rollup -c 2>&1",
"build:samples": "echo skipped.",
"build:test": "tsc -p . && dev-tool run bundle",
"build:test": "dev-tool run build-package && dev-tool run bundle",
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"test/**/*.ts\"",
"clean": "dev-tool run vendored rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log",
"execute:samples": "echo skipped",
@ -54,15 +51,15 @@
"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",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"unit-test:browser": "dev-tool run test:browser",
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
"unit-test:node": "dev-tool run test:vitest",
"update-snippets": "echo skipped"
},
"sideEffects": false,
"autoPublish": false,
"dependencies": {
"@azure-rest/core-client": "^1.4.0",
"@azure/communication-common": "^2.2.0",
"@azure-rest/core-client": "^2.3.1",
"@azure/communication-common": "^2.3.1",
"@azure/core-auth": "^1.6.0",
"@azure/core-paging": "^1.5.0",
"@azure/core-rest-pipeline": "^1.12.0",
@ -71,33 +68,22 @@
"tslib": "^2.2.0"
},
"devDependencies": {
"@azure-tools/test-credential": "^1.0.0",
"@azure-tools/test-recorder": "^3.0.0",
"@azure-tools/test-credential": "^2.0.0",
"@azure-tools/test-recorder": "^4.1.0",
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/identity": "^4.2.1",
"@types/chai": "^4.2.8",
"@types/mocha": "^10.0.0",
"@types/node": "^18.0.0",
"@vitest/browser": "^2.1.5",
"@vitest/coverage-istanbul": "^2.1.5",
"autorest": "latest",
"chai": "^4.2.0",
"dotenv": "^16.0.0",
"eslint": "^9.9.0",
"karma": "^6.2.0",
"karma-chrome-launcher": "^3.0.0",
"karma-coverage": "^2.0.0",
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^2.1.2",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-source-map-support": "~1.4.0",
"karma-sourcemap-loader": "^0.4.0",
"mocha": "^10.0.0",
"nyc": "^17.0.0",
"source-map-support": "^0.5.9",
"ts-node": "^10.0.0",
"typescript": "~5.6.2"
"playwright": "^1.48.2",
"typescript": "~5.6.2",
"vitest": "^2.1.5"
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-messages-rest-rest/README.md",
"//metadata": {
@ -108,9 +94,7 @@
}
]
},
"browser": {
"./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js"
},
"browser": "./dist/browser/index.js",
"//sampleConfiguration": {
"productName": "Azure client library for Azure Communication Messages Services",
"productSlugs": [
@ -118,5 +102,42 @@
"azure-communication-services"
],
"apiRefLink": "https://learn.microsoft.com/javascript/api/overview/azure/communication-messages-rest-readme?view=azure-node-latest"
},
"type": "module",
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
},
"dialects": [
"esm",
"commonjs"
],
"esmDialects": [
"browser",
"react-native"
],
"selfLink": false
},
"exports": {
"./package.json": "./package.json",
".": {
"browser": {
"types": "./dist/browser/index.d.ts",
"default": "./dist/browser/index.js"
},
"react-native": {
"types": "./dist/react-native/index.d.ts",
"default": "./dist/react-native/index.js"
},
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
}
}

Просмотреть файл

@ -7,7 +7,7 @@
import NotificationClient from "@azure-rest/communication-messages";
import { AzureKeyCredential } from "@azure/core-auth";
import * as fs from "fs";
import * as fs from "node:fs";
// Load the .env file if it exists
import * as dotenv from "dotenv";

Просмотреть файл

@ -5,7 +5,7 @@ import {
GetMediaParameters,
SendParameters,
ListTemplatesParameters,
} from "./parameters";
} from "./parameters.js";
import {
GetMedia200Response,
GetMediaDefaultResponse,
@ -13,7 +13,7 @@ import {
SendDefaultResponse,
ListTemplates200Response,
ListTemplatesDefaultResponse,
} from "./responses";
} from "./responses.js";
import { Client, StreamableMethod } from "@azure-rest/core-client";
export interface GetMedia {

Просмотреть файл

@ -1,15 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import MessagesServiceClient from "./messagesServiceClient";
import MessagesServiceClient from "./messagesServiceClient.js";
export * from "./messagesServiceClient";
export * from "./parameters";
export * from "./responses";
export * from "./clientDefinitions";
export * from "./isUnexpected";
export * from "./models";
export * from "./outputModels";
export * from "./paginateHelper";
export * from "./messagesServiceClient.js";
export * from "./parameters.js";
export * from "./responses.js";
export * from "./clientDefinitions.js";
export * from "./isUnexpected.js";
export * from "./models.js";
export * from "./outputModels.js";
export * from "./paginateHelper.js";
export default MessagesServiceClient;

Просмотреть файл

@ -8,7 +8,7 @@ import {
SendDefaultResponse,
ListTemplates200Response,
ListTemplatesDefaultResponse,
} from "./responses";
} from "./responses.js";
const responseMap: Record<string, string[]> = {
"GET /messages/streams/{id}": ["200"],

Просмотреть файл

@ -2,9 +2,9 @@
// Licensed under the MIT License.
import { getClient, ClientOptions } from "@azure-rest/core-client";
import { logger } from "./logger";
import { logger } from "./logger.js";
import { TokenCredential, KeyCredential } from "@azure/core-auth";
import { MessagesServiceClient } from "./clientDefinitions";
import { MessagesServiceClient } from "./clientDefinitions.js";
/** The optional parameters for the client */
export interface MessagesServiceClientOptions extends ClientOptions {

Просмотреть файл

@ -3,7 +3,7 @@
import { RawHttpHeadersInput } from "@azure/core-rest-pipeline";
import { RequestParameters } from "@azure-rest/core-client";
import { NotificationContent } from "./models";
import { NotificationContent } from "./models.js";
export interface GetMediaHeaders {
/** An opaque, globally-unique, client-generated string identifier for the request. */

Просмотреть файл

@ -7,7 +7,7 @@ import {
RepeatabilityResultOutput,
SendMessageResultOutput,
PagedMessageTemplateItemOutput,
} from "./outputModels";
} from "./outputModels.js";
export interface GetMedia200Headers {
/** An opaque, globally-unique, client-generated string identifier for the request. */

Просмотреть файл

@ -1,13 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import MessagesServiceClient from "./messagesServiceClient";
export * from "./generated/src/messagesServiceClient";
export * from "./generated/src/parameters";
export * from "./generated/src/responses";
export * from "./generated/src/clientDefinitions";
export * from "./generated/src/isUnexpected";
export * from "./generated/src/models";
export * from "./generated/src/outputModels";
export * from "./generated/src/paginateHelper";
import MessagesServiceClient from "./messagesServiceClient.js";
export * from "./generated/src/messagesServiceClient.js";
export * from "./generated/src/parameters.js";
export * from "./generated/src/responses.js";
export * from "./generated/src/clientDefinitions.js";
export * from "./generated/src/isUnexpected.js";
export * from "./generated/src/models.js";
export * from "./generated/src/outputModels.js";
export * from "./generated/src/paginateHelper.js";
export default MessagesServiceClient;

Просмотреть файл

@ -5,8 +5,8 @@ import type { TokenCredential, KeyCredential } from "@azure/core-auth";
import { isTokenCredential, isKeyCredential } from "@azure/core-auth";
import type { ClientOptions } from "@azure-rest/core-client";
import { parseClientArguments, createCommunicationAuthPolicy } from "@azure/communication-common";
import type { MessagesServiceClient } from "./generated/src/clientDefinitions";
import GeneratedAzureCommunicationMessageServiceClient from "./generated/src/messagesServiceClient";
import type { MessagesServiceClient } from "./generated/src/clientDefinitions.js";
import GeneratedAzureCommunicationMessageServiceClient from "./generated/src/messagesServiceClient.js";
/**
* Initialize a new instance of `MessagesServiceClient`

Просмотреть файл

@ -3,9 +3,7 @@
import type { Recorder } from "@azure-tools/test-recorder";
import { env } from "@azure-tools/test-recorder";
import { assert } from "chai";
import { createRecorderWithConnectionString } from "./utils/recordedClient";
import type { Context } from "mocha";
import { createRecorderWithConnectionString } from "./utils/recordedClient.js";
import type {
MessagesServiceClient,
Send202Response,
@ -17,23 +15,24 @@ import type {
AudioNotificationContent,
VideoNotificationContent,
DocumentNotificationContent,
} from "../../src/generated/src";
} from "../../src/generated/src/index.js";
import { describe, it, assert, beforeEach, afterEach } from "vitest";
describe("Notification Messages Test", () => {
let recorder: Recorder;
let client: MessagesServiceClient;
beforeEach(async function (this: Context) {
({ client, recorder } = await createRecorderWithConnectionString(this));
beforeEach(async (ctx) => {
({ client, recorder } = await createRecorderWithConnectionString(ctx));
});
afterEach(async function () {
if (!this.currentTest?.isPending()) {
afterEach(async (ctx) => {
if (!ctx.task.pending) {
await recorder.stop();
}
});
it("send simple text message test", async function () {
it("send simple text message test", async () => {
const result = await client.path("/messages/notifications:send").post({
contentType: "application/json",
body: {
@ -49,7 +48,7 @@ describe("Notification Messages Test", () => {
assert.isDefined(response.body.receipts[0].messageId);
});
it("send document message test", async function () {
it("send document message test", async () => {
const documentMessage: DocumentNotificationContent = {
kind: "document",
mediaUri: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
@ -67,7 +66,7 @@ describe("Notification Messages Test", () => {
assert.isDefined(response.body.receipts[0].messageId);
});
it("send video message test", async function () {
it("send video message test", async () => {
const videoMessage: VideoNotificationContent = {
kind: "video",
mediaUri: "https://sample-videos.com/video321/mp4/480/big_buck_bunny_480p_1mb.mp4",
@ -85,7 +84,7 @@ describe("Notification Messages Test", () => {
assert.isDefined(response.body.receipts[0].messageId);
});
it("send audio message test", async function () {
it("send audio message test", async () => {
const audioMessage: AudioNotificationContent = {
kind: "audio",
mediaUri: "https://sample-videos.com/audio/mp3/wave.mp3",
@ -103,7 +102,7 @@ describe("Notification Messages Test", () => {
assert.isDefined(response.body.receipts[0].messageId);
});
it("send image message test", async function () {
it("send image message test", async () => {
const imageMessage: ImageNotificationContent = {
kind: "image",
mediaUri: "https://www.w3schools.com/w3css/img_lights.jpg",
@ -122,7 +121,7 @@ describe("Notification Messages Test", () => {
assert.isDefined(response.body.receipts[0].messageId);
});
it("send simple text template message test", async function () {
it("send simple text template message test", async () => {
const DaysTemplateValue: MessageTemplateValue = {
kind: "text",
name: "Days",
@ -160,7 +159,7 @@ describe("Notification Messages Test", () => {
assert.isDefined(response.body.receipts[0].messageId);
});
it("send template message with video test", async function () {
it("send template message with video test", async () => {
const HeaderVideo: MessageTemplateValue = {
kind: "video",
name: "HappyHourVideo",
@ -218,7 +217,7 @@ describe("Notification Messages Test", () => {
assert.isDefined(response.body.receipts[0].messageId);
});
it("send template message with image test", async function () {
it("send template message with image test", async () => {
const HeaderImage: MessageTemplateValue = {
kind: "image",
name: "CompanyPhoto",
@ -267,7 +266,7 @@ describe("Notification Messages Test", () => {
assert.isDefined(response.body.receipts[0].messageId);
});
it("send template message with document test", async function () {
it("send template message with document test", async () => {
const HeaderDoc: MessageTemplateValue = {
kind: "document",
name: "BoardingPass",
@ -334,7 +333,7 @@ describe("Notification Messages Test", () => {
assert.isDefined(response.body.receipts[0].messageId);
});
it("send template message with quick reply buttons test", async function () {
it("send template message with quick reply buttons test", async () => {
const NameTemplateValue: MessageTemplateValue = {
kind: "text",
name: "NameValue",
@ -399,17 +398,17 @@ describe("Message Template Read Test", () => {
let recorder: Recorder;
let client: MessagesServiceClient;
beforeEach(async function (this: Context) {
({ client, recorder } = await createRecorderWithConnectionString(this));
beforeEach(async (ctx) => {
({ client, recorder } = await createRecorderWithConnectionString(ctx));
});
afterEach(async function () {
if (!this.currentTest?.isPending()) {
afterEach(async (ctx) => {
if (!ctx.task.pending) {
await recorder.stop();
}
});
it("get template test", async function () {
it("get template test", async () => {
const result = await client
.path("/messages/channels/{channelId}/templates", env.CHANNEL_ID || "")
.get();

Просмотреть файл

@ -1,11 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import type { Context, Test } from "mocha";
import type { RecorderStartOptions, SanitizerOptions } from "@azure-tools/test-recorder";
import type { RecorderStartOptions, SanitizerOptions, TestInfo } from "@azure-tools/test-recorder";
import { Recorder, env } from "@azure-tools/test-recorder";
import type { MessagesServiceClient } from "../../../src";
import MessageClient from "../../../src";
import type { MessagesServiceClient } from "../../../src/index.js";
import MessageClient from "../../../src/index.js";
import { parseConnectionString } from "@azure/communication-common";
import type { TokenCredential } from "@azure/core-auth";
import { createTestCredential } from "@azure-tools/test-credential";
@ -57,7 +55,7 @@ const recorderEnvSetup: RecorderStartOptions = {
* 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: Test | undefined): Promise<Recorder> {
export async function createRecorder(context: TestInfo | undefined): Promise<Recorder> {
const recorder = new Recorder(context);
await recorder.start(recorderEnvSetup);
await recorder.setMatcher("CustomDefaultMatcher", {
@ -71,8 +69,8 @@ export async function createRecorder(context: Test | undefined): Promise<Recorde
return recorder;
}
export async function createRecorderWithToken(context: Context): Promise<RecordedMessageClient> {
const recorder = await createRecorder(context.currentTest);
export async function createRecorderWithToken(context: TestInfo): Promise<RecordedMessageClient> {
const recorder = await createRecorder(context);
const credential: TokenCredential = createTestCredential();
const endpoint = parseConnectionString(
@ -86,9 +84,9 @@ export async function createRecorderWithToken(context: Context): Promise<Recorde
}
export async function createRecorderWithConnectionString(
context: Context,
context: TestInfo,
): Promise<RecordedMessageClient> {
const recorder = await createRecorder(context.currentTest);
const recorder = await createRecorder(context);
const client = MessageClient(
env.COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING ?? "",

Просмотреть файл

@ -0,0 +1,10 @@
{
"extends": "./.tshy/build.json",
"include": ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.spec.ts", "./test/**/*.mts"],
"exclude": ["./test/**/node/**/*.ts"],
"compilerOptions": {
"outDir": "./dist-test/browser",
"rootDir": ".",
"skipLibCheck": true
}
}

Просмотреть файл

@ -1,11 +1,20 @@
{
"extends": "../../../tsconfig",
"compilerOptions": {
"outDir": "./dist-esm",
"declarationDir": "./types",
"paths": {
"@azure-rest/communication-messages": ["./src/index"]
}
},
"module": "NodeNext",
"moduleResolution": "NodeNext",
"rootDir": "."
},
"include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"]
"include": [
"src/**/*.ts",
"src/**/*.mts",
"src/**/*.cts",
"samples-dev/**/*.ts",
"test/**/*.ts",
"test/**/*.mts",
"test/**/*.cts"
]
}

Просмотреть файл

@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { defineConfig, mergeConfig } from "vitest/config";
import viteConfig from "../../../vitest.browser.shared.config.ts";
export default mergeConfig(
viteConfig,
defineConfig({
test: {
include: ["dist-test/browser/test/**/*.spec.js"],
hookTimeout: 5000000,
testTimeout: 5000000,
},
}),
);

Просмотреть файл

@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { defineConfig, mergeConfig } from "vitest/config";
import viteConfig from "../../../vitest.shared.config.ts";
export default mergeConfig(
viteConfig,
defineConfig({
test: {
include: ["test/**/*.spec.ts"],
hookTimeout: 5000000,
testTimeout: 5000000,
},
}),
);