Skip to content

Commit cd311b7

Browse files
[Communication Chat] Migrate communication-chat tests to the new recorder (Azure#20278)
* migrate comm-chat tests to the new recorder * mask token * dummy commit * Update sdk/communication/ci.yml
1 parent 09f6653 commit cd311b7

File tree

54 files changed

+2604
-1156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2604
-1156
lines changed

sdk/communication/communication-chat/karma.conf.js

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// https://github.com/karma-runner/karma-chrome-launcher
22
process.env.CHROME_BIN = require("puppeteer").executablePath();
3+
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
4+
35
require("dotenv").config();
4-
const {
5-
jsonRecordingFilterFunction,
6-
isPlaybackMode,
7-
isSoftRecordMode,
8-
isRecordMode,
9-
} = require("@azure-tools/test-recorder");
6+
7+
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
108

119
module.exports = function (config) {
1210
config.set({
@@ -28,14 +26,10 @@ module.exports = function (config) {
2826
"karma-coverage",
2927
"karma-sourcemap-loader",
3028
"karma-junit-reporter",
31-
"karma-json-to-file-reporter",
32-
"karma-json-preprocessor",
3329
],
3430

3531
// list of files / patterns to load in the browser
36-
files: ["dist-test/index.browser.js"].concat(
37-
isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []
38-
),
32+
files: ["dist-test/index.browser.js"],
3933

4034
// list of files / patterns to exclude
4135
exclude: [],
@@ -44,7 +38,6 @@ module.exports = function (config) {
4438
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
4539
preprocessors: {
4640
"**/*.js": ["sourcemap", "env"],
47-
"recordings/browsers/**/*.json": ["json"],
4841
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
4942
// Preprocess source file to calculate code coverage, however this will make source file unreadable
5043
//"dist-test/index.browser.js": ["coverage"]
@@ -53,12 +46,17 @@ module.exports = function (config) {
5346
// inject following environment values into browser testing with window.__env__
5447
// environment values MUST be exported or set with same console running "karma start"
5548
// https://www.npmjs.com/package/karma-env-preprocessor
56-
envPreprocessor: ["TEST_MODE", "COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING", "BASE_URL"],
49+
envPreprocessor: [
50+
"TEST_MODE",
51+
"COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING",
52+
"BASE_URL",
53+
"RECORDINGS_RELATIVE_PATH",
54+
],
5755

5856
// test results reporter to use
5957
// possible values: 'dots', 'progress'
6058
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
61-
reporters: ["mocha", "coverage", "junit", "json-to-file"],
59+
reporters: ["mocha", "coverage", "junit"],
6260

6361
coverageReporter: {
6462
// specify a common output directory
@@ -81,11 +79,6 @@ module.exports = function (config) {
8179
properties: {}, // key value pair of properties to add to the <properties> section of the report
8280
},
8381

84-
jsonToFileReporter: {
85-
filter: jsonRecordingFilterFunction,
86-
outputPath: ".",
87-
},
88-
8982
// web server port
9083
port: 9876,
9184

@@ -122,9 +115,6 @@ module.exports = function (config) {
122115
browserNoActivityTimeout: 600000,
123116
browserDisconnectTimeout: 10000,
124117
browserDisconnectTolerance: 3,
125-
browserConsoleLogOptions: {
126-
terminal: !isRecordMode(),
127-
},
128118

129119
client: {
130120
mocha: {

sdk/communication/communication-chat/package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
"extract-api": "tsc -p . && api-extractor run --local",
2020
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
2121
"generate:client": "autorest --typescript ./swagger/README.md && rushx format",
22-
"integration-test:browser": "karma start --single-run",
23-
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace -t 300000 dist-esm/test/public/*.spec.js dist-esm/test/public/node/*.spec.js",
22+
"integration-test:browser": "dev-tool run test:browser",
23+
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
2424
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
2525
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
2626
"lint": "eslint package.json api-extractor.json src test --ext .ts",
2727
"pack": "npm pack 2>&1",
28-
"test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
29-
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
28+
"test:browser": "npm run build:test && npm run unit-test:browser",
29+
"test:node": "npm run build:test && npm run unit-test:node",
3030
"test": "npm run build:test && npm run unit-test && npm run integration-test",
31-
"unit-test:browser": "karma start --single-run",
32-
"unit-test:node": "cross-env TS_NODE_FILES=true TS_NODE_COMPILER_OPTIONS=\"{\\\"module\\\":\\\"commonjs\\\"}\" mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace \"test/{,!(browser)/**/}*.spec.ts\"",
31+
"unit-test:browser": "dev-tool run test:browser",
32+
"unit-test:node": "cross-env TS_NODE_FILES=true TS_NODE_COMPILER_OPTIONS=\"{\\\"module\\\":\\\"commonjs\\\"}\" dev-tool run test:node-ts-input -- --timeout 1200000 'test/**/*.spec.ts'",
3333
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
3434
},
3535
"files": [
@@ -80,7 +80,8 @@
8080
"@azure/communication-identity": "^1.0.0",
8181
"@azure/dev-tool": "^1.0.0",
8282
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
83-
"@azure-tools/test-recorder": "^1.0.0",
83+
"@azure-tools/test-credential": "^1.0.0",
84+
"@azure-tools/test-recorder": "^2.0.0",
8485
"@microsoft/api-extractor": "^7.18.11",
8586
"@types/chai": "^4.1.6",
8687
"@types/mocha": "^7.0.2",

sdk/communication/communication-chat/recordings/browsers/chatclient_chat_operations/recording_successfully_creates_a_thread.json

Lines changed: 186 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)