Skip to content

Commit 1dbc177

Browse files
[Form Recognizer] Migrate tests to the new recorder (Azure#20264)
* checkpoint * delete recordings * test update * more updates and recordingz * .json * lint * fr remianing tests * package.json
1 parent f878d73 commit 1dbc177

File tree

173 files changed

+145534
-11585
lines changed

Some content is hidden

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

173 files changed

+145534
-11585
lines changed

sdk/formrecognizer/ai-form-recognizer/karma.conf.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33

44
// https://github.com/karma-runner/karma-chrome-launcher
55
process.env.CHROME_BIN = require("puppeteer").executablePath();
6+
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
67
require("dotenv").config();
7-
const {
8-
jsonRecordingFilterFunction,
9-
isPlaybackMode,
10-
isSoftRecordMode,
11-
isRecordMode,
12-
} = require("@azure-tools/test-recorder");
8+
9+
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
1310

1411
module.exports = function (config) {
1512
config.set({
@@ -31,15 +28,13 @@ module.exports = function (config) {
3128
"karma-coverage",
3229
"karma-sourcemap-loader",
3330
"karma-junit-reporter",
34-
"karma-json-to-file-reporter",
35-
"karma-json-preprocessor",
3631
],
3732

3833
// list of files / patterns to load in the browser
3934
files: [
4035
"dist-test/index.browser.js",
4136
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true },
42-
].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []),
37+
],
4338

4439
// list of files / patterns to exclude
4540
exclude: [],
@@ -48,7 +43,6 @@ module.exports = function (config) {
4843
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
4944
preprocessors: {
5045
"**/*.js": ["sourcemap", "env"],
51-
"recordings/browsers/**/*.json": ["json"],
5246
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
5347
// Preprocess source file to calculate code coverage, however this will make source file unreadable
5448
//"dist-test/index.browser.js": ["coverage"]
@@ -66,12 +60,13 @@ module.exports = function (config) {
6660
"AZURE_CLIENT_ID",
6761
"AZURE_CLIENT_SECRET",
6862
"AZURE_TENANT_ID",
63+
"RECORDINGS_RELATIVE_PATH",
6964
],
7065

7166
// test results reporter to use
7267
// possible values: 'dots', 'progress'
7368
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
74-
reporters: ["mocha", "coverage", "junit", "json-to-file"],
69+
reporters: ["mocha", "coverage", "junit"],
7570

7671
coverageReporter: {
7772
// specify a common output directory
@@ -94,11 +89,6 @@ module.exports = function (config) {
9489
properties: {}, // key value pair of properties to add to the <properties> section of the report
9590
},
9691

97-
jsonToFileReporter: {
98-
filter: jsonRecordingFilterFunction,
99-
outputPath: ".",
100-
},
101-
10292
// web server port
10393
port: 9876,
10494

@@ -133,9 +123,6 @@ module.exports = function (config) {
133123
browserNoActivityTimeout: 600000,
134124
browserDisconnectTimeout: 10000,
135125
browserDisconnectTolerance: 3,
136-
browserConsoleLogOptions: {
137-
terminal: !isRecordMode(),
138-
},
139126

140127
client: {
141128
mocha: {

sdk/formrecognizer/ai-form-recognizer/package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@
6363
"execute:samples": "dev-tool samples run samples-dev/",
6464
"extract-api": "tsc -p . && api-extractor run --local",
6565
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
66-
"integration-test:browser": "karma start --single-run",
67-
"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/*/{,!(browser)/**/}*.spec.js\"",
66+
"integration-test:browser": "dev-tool run test:browser",
67+
"integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' \"test/**/*.spec.ts\"",
6868
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
6969
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
7070
"lint": "eslint package.json api-extractor.json src test --ext .ts",
7171
"pack": "npm pack 2>&1",
72-
"test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
73-
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
72+
"test:browser": "npm run build:test && npm run unit-test:browser",
73+
"test:node": "npm run build:test && npm run unit-test:node",
7474
"test": "npm run build:test && npm run unit-test && npm run integration-test",
75-
"unit-test:browser": "karma start --single-run",
76-
"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\"",
75+
"unit-test:browser": "dev-tool run test:browser",
76+
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' \"test/**/*.spec.ts\" \"test/**/node/*.spec.ts\"",
7777
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
7878
},
7979
"sideEffects": false,
@@ -95,7 +95,8 @@
9595
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
9696
"@azure/identity": "^2.0.1",
9797
"@azure/test-utils": "^1.0.0",
98-
"@azure-tools/test-recorder": "^1.0.0",
98+
"@azure-tools/test-credential": "^1.0.0",
99+
"@azure-tools/test-recorder": "^2.0.0",
99100
"@microsoft/api-extractor": "^7.18.11",
100101
"@types/chai": "^4.1.6",
101102
"@types/mocha": "^7.0.2",
@@ -113,8 +114,6 @@
113114
"karma-env-preprocessor": "^0.1.1",
114115
"karma-firefox-launcher": "^1.1.0",
115116
"karma-ie-launcher": "^1.0.0",
116-
"karma-json-preprocessor": "^0.3.3",
117-
"karma-json-to-file-reporter": "^1.0.1",
118117
"karma-junit-reporter": "^2.0.1",
119118
"karma-mocha": "^2.0.1",
120119
"karma-mocha-reporter": "^2.2.5",

0 commit comments

Comments
 (0)