Skip to content

Commit

Permalink
[synapse-spark] Migrate test recorder (#24508)
Browse files Browse the repository at this point in the history
  • Loading branch information
minhanh-phan authored Jan 19, 2023
1 parent 10caad0 commit b894fa6
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 481 deletions.
30 changes: 8 additions & 22 deletions sdk/synapse/synapse-spark/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
// https://github.com/karma-runner/karma-chrome-launcher
process.env.CHROME_BIN = require("puppeteer").executablePath();
require("dotenv").config();
const {
jsonRecordingFilterFunction,
isPlaybackMode,
isSoftRecordMode,
isRecordMode
} = require("@azure-tools/test-recorder");
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();

module.exports = function(config) {
config.set({
Expand All @@ -31,25 +27,22 @@ module.exports = function(config) {
"karma-coverage",
"karma-sourcemap-loader",
"karma-junit-reporter",
"karma-json-to-file-reporter",
"karma-source-map-support",
"karma-json-preprocessor"
"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 }
].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []),
],

// 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"],
"recordings/browsers/**/*.json": ["json"]
"**/*.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"]
Expand All @@ -60,13 +53,14 @@ module.exports = function(config) {
"ENDPOINT",
"AZURE_CLIENT_ID",
"AZURE_CLIENT_SECRET",
"AZURE_TENANT_ID"
"AZURE_TENANT_ID",
"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", "json-to-file"],
reporters: ["mocha", "coverage", "junit"],

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

jsonToFileReporter: {
filter: jsonRecordingFilterFunction,
outputPath: "."
},

// web server port
port: 9876,

Expand Down Expand Up @@ -128,9 +117,6 @@ module.exports = function(config) {
browserNoActivityTimeout: 60000000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
browserConsoleLogOptions: {
terminal: !isRecordMode()
},

client: {
mocha: {
Expand Down
10 changes: 4 additions & 6 deletions sdk/synapse/synapse-spark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@microsoft/api-extractor": "^7.31.1",
"@azure-tools/test-recorder": "^1.0.0",
"@azure-tools/test-credential": "^1.0.0",
"@azure-tools/test-recorder": "^2.0.0",
"@azure/test-utils": "^1.0.0",
"@azure/identity": "^2.0.1",
"@types/chai": "^4.1.6",
"@types/chai-as-promised": "^7.1.0",
"@types/mocha": "^7.0.2",
Expand All @@ -50,8 +50,6 @@
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^1.1.0",
"karma-ie-launcher": "^1.0.0",
"karma-json-preprocessor": "^0.3.3",
"karma-json-to-file-reporter": "^1.0.1",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
Expand Down Expand Up @@ -107,8 +105,8 @@
"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",
"test": "npm run clean && npm run build:test && npm run unit-test",
"unit-test:browser": "karma start --single-run",
"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\"",
"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": "npm run unit-test:node && npm run unit-test:browser",
"extract-api": "api-extractor run --local",
"clean": "rimraf dist dist-* temp types *.tgz *.log",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b894fa6

Please sign in to comment.