Skip to content

Commit 0f9ba98

Browse files
[document translator] Migrate to new recorder (Azure#20132)
* Migrate to new recorder * fix tests * Fix format * Fix lint * CI Config Co-authored-by: Harsha Nalluru <[email protected]>
1 parent 55a93fb commit 0f9ba98

File tree

11 files changed

+584
-186
lines changed

11 files changed

+584
-186
lines changed

sdk/documenttranslator/ai-document-translator-rest/karma.conf.js

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

1411
module.exports = function (config) {
1512
config.set({
@@ -40,27 +37,30 @@ module.exports = function (config) {
4037
files: [
4138
"dist-test/index.browser.js",
4239
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true },
43-
].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []),
44-
40+
],
4541
// list of files / patterns to exclude
4642
exclude: [],
4743

4844
// preprocess matching files before serving them to the browser
4945
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
5046
preprocessors: {
5147
"**/*.js": ["sourcemap", "env"],
52-
"recordings/browsers/**/*.json": ["json"],
5348
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
5449
// Preprocess source file to calculate code coverage, however this will make source file unreadable
5550
// "dist-test/index.js": ["coverage"]
5651
},
5752

58-
envPreprocessor: ["TEST_MODE", "ENDPOINT", "DOCUMENT_TRANSLATOR_API_KEY"],
53+
envPreprocessor: [
54+
"TEST_MODE",
55+
"ENDPOINT",
56+
"DOCUMENT_TRANSLATOR_API_KEY",
57+
"RECORDINGS_RELATIVE_PATH",
58+
],
5959

6060
// test results reporter to use
6161
// possible values: 'dots', 'progress'
6262
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
63-
reporters: ["mocha", "coverage", "junit", "json-to-file"],
63+
reporters: ["mocha", "coverage", "junit"],
6464

6565
coverageReporter: {
6666
// specify a common output directory
@@ -83,11 +83,6 @@ module.exports = function (config) {
8383
properties: {}, // key value pair of properties to add to the <properties> section of the report
8484
},
8585

86-
jsonToFileReporter: {
87-
filter: jsonRecordingFilterFunction,
88-
outputPath: ".",
89-
},
90-
9186
// web server port
9287
port: 9876,
9388

@@ -122,9 +117,6 @@ module.exports = function (config) {
122117
browserNoActivityTimeout: 60000000,
123118
browserDisconnectTimeout: 10000,
124119
browserDisconnectTolerance: 3,
125-
browserConsoleLogOptions: {
126-
terminal: !isRecordMode(),
127-
},
128120

129121
client: {
130122
mocha: {

sdk/documenttranslator/ai-document-translator-rest/package.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
"Azure Cognitive Services instance": "https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account"
5555
}
5656
},
57-
"browser": {
58-
"./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js"
59-
},
6057
"scripts": {
6158
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
6259
"build:browser": "tsc -p . && dev-tool run bundle",
@@ -71,33 +68,34 @@
7168
"extract-api": "tsc -p . && api-extractor run --local",
7269
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
7370
"generate:client": "autorest --typescript swagger/README.md && npm run format",
74-
"integration-test:browser": "karma start --single-run",
75-
"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/{,!(browser)/**/}*.spec.js\"",
71+
"integration-test:browser": "dev-tool run test:browser",
72+
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
7673
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
7774
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
7875
"lint": "eslint package.json api-extractor.json src test --ext .ts",
7976
"pack": "npm pack 2>&1",
8077
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser",
8178
"test:node": "npm run clean && npm run build:test && npm run unit-test:node",
8279
"test": "npm run clean && npm run build:test && npm run unit-test",
83-
"unit-test:browser": "karma start --single-run",
84-
"unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"",
80+
"unit-test:browser": "dev-tool run test:browser",
81+
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
8582
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
8683
},
8784
"sideEffects": false,
8885
"autoPublish": false,
8986
"dependencies": {
9087
"@azure/core-auth": "^1.3.0",
91-
"@azure-rest/core-client": "1.0.0-beta.7",
88+
"@azure-rest/core-client": "1.0.0-beta.9",
9289
"@azure/core-rest-pipeline": "^1.1.0",
9390
"@azure/logger": "^1.0.0",
94-
"tslib": "^2.2.0"
91+
"tslib": "^2.2.0",
92+
"@azure-tools/test-recorder": "^2.0.0"
9593
},
9694
"devDependencies": {
9795
"@azure/dev-tool": "^1.0.0",
9896
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
9997
"@azure/identity": "^2.0.1",
100-
"@azure-tools/test-recorder": "^1.0.0",
98+
"@azure-tools/test-credential": "^1.0.0",
10199
"@microsoft/api-extractor": "^7.18.11",
102100
"@types/chai": "^4.1.6",
103101
"@types/mocha": "^7.0.2",

0 commit comments

Comments
 (0)