Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test Utils] [Recorder] Migrate to esm #28667

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
e503d82
unreleased
HarshaNalluru Sep 22, 2023
b34f67c
Merge branch 'main' of https://github.com/harshanalluru/azure-sdk-for-js
HarshaNalluru Sep 26, 2023
505f1b3
empty
HarshaNalluru Sep 26, 2023
2fe1ffb
Merge branch 'Azure:main' into main
HarshaNalluru Oct 23, 2023
5619dcf
Merge branch 'main' of https://github.com/harshanalluru/azure-sdk-for-js
HarshaNalluru Oct 31, 2023
973988d
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js
HarshaNalluru Nov 23, 2023
5c3718b
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js
HarshaNalluru Dec 7, 2023
1621db1
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js
HarshaNalluru Dec 19, 2023
b203af9
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js
HarshaNalluru Jan 23, 2024
31bf8d1
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js
HarshaNalluru Feb 6, 2024
ef9c226
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js
HarshaNalluru Feb 9, 2024
4c14b2a
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js
HarshaNalluru Feb 13, 2024
693683c
[test-recorder] Support test context from vitest (#28350)
jeremymeng Jan 31, 2024
0a0d56b
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js
HarshaNalluru Feb 22, 2024
cbd8105
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js
HarshaNalluru Feb 23, 2024
4d055b5
first draft - before fixing test build failures
HarshaNalluru Feb 26, 2024
ffb931c
Merge branch 'recorder/vitest-context' of https://github.com/jeremyme…
HarshaNalluru Feb 26, 2024
cdff879
fixing tests halfway
HarshaNalluru Feb 26, 2024
0893aba
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Feb 26, 2024
66a8c03
lock file
HarshaNalluru Feb 26, 2024
e45d1a9
lock file
HarshaNalluru Feb 26, 2024
59e6787
final fixes to tests
HarshaNalluru Feb 27, 2024
bcdebcd
expose more types
HarshaNalluru Feb 27, 2024
4bfc467
Merge branch 'recorder/vitest-context' of https://github.com/jeremyme…
HarshaNalluru Feb 29, 2024
c8ba527
node tests work fine, browser tests... figuring out
HarshaNalluru Feb 29, 2024
2348844
checkpoint
HarshaNalluru Feb 29, 2024
ad16125
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Feb 29, 2024
f12bcc7
dummy commit
HarshaNalluru Feb 29, 2024
e9e432a
dummy commit
HarshaNalluru Feb 29, 2024
dc6813d
format and lock file
HarshaNalluru Feb 29, 2024
0d586fb
typedoc fixes
HarshaNalluru Mar 1, 2024
babc232
dummy commit
HarshaNalluru Mar 1, 2024
c539c73
pre-hook
HarshaNalluru Mar 1, 2024
fa143ff
disable web security
HarshaNalluru Mar 5, 2024
71e9f64
checkpoint - both browser and node tests working fine
HarshaNalluru Mar 9, 2024
d9c5736
format
HarshaNalluru Mar 9, 2024
1164e32
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 9, 2024
415c91f
node and browser work fine - checkpoint - recorder
HarshaNalluru Mar 9, 2024
2a8935b
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 11, 2024
4178384
tsconfig
HarshaNalluru Mar 11, 2024
0769e0f
lock file
HarshaNalluru Mar 11, 2024
2b28254
app-config changes
HarshaNalluru Mar 14, 2024
aaeafa7
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 14, 2024
8d2e0a0
fix conflict
HarshaNalluru Mar 14, 2024
cf6e783
4.0.0 recorder 👶
HarshaNalluru Mar 14, 2024
c72ed28
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 19, 2024
1d435c4
lock file
HarshaNalluru Mar 19, 2024
8ef9862
switch template
HarshaNalluru Mar 19, 2024
923c25e
revert app-config
HarshaNalluru Mar 19, 2024
ec64e7e
revert app-config
HarshaNalluru Mar 19, 2024
9bb7b36
lock file
HarshaNalluru Mar 19, 2024
ad314b2
template update
HarshaNalluru Mar 19, 2024
7e83492
update test credential package
HarshaNalluru Mar 21, 2024
ee3524f
changelog
HarshaNalluru Mar 21, 2024
0e1c678
make "@azure-tools/test-credential" version consistent
HarshaNalluru Mar 21, 2024
7746859
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 21, 2024
6cf7fc9
Merge branch 'harshan/publish-test-credential-current' of https://git…
HarshaNalluru Mar 21, 2024
48febd3
lock file
HarshaNalluru Mar 21, 2024
c51536c
lock file
HarshaNalluru Mar 21, 2024
cb9a7d9
lock file and clean up
HarshaNalluru Mar 21, 2024
9d805e1
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 21, 2024
09632d6
revert non recorder changes
HarshaNalluru Mar 21, 2024
4407b05
more reversions
HarshaNalluru Mar 21, 2024
c95c077
lock file
HarshaNalluru Mar 21, 2024
e0a9360
revert template
HarshaNalluru Mar 21, 2024
7dc8322
correct reversion for template
HarshaNalluru Mar 21, 2024
6e25e4d
clean up
HarshaNalluru Mar 21, 2024
f15502b
changelog
HarshaNalluru Mar 21, 2024
9c6f0c6
remove console.logs and address comments
HarshaNalluru Mar 21, 2024
1d2bc19
format
HarshaNalluru Mar 21, 2024
e92441d
fix tests
HarshaNalluru Mar 21, 2024
a3251b7
address feedback
HarshaNalluru Mar 29, 2024
6456ff7
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 29, 2024
7ab816e
lock file
HarshaNalluru Mar 29, 2024
303f2f2
Apply suggestions from code review
mpodwysocki Mar 29, 2024
6b50763
Update sdk/test-utils/recorder/package.json
mpodwysocki Mar 29, 2024
c4b905c
lock file
HarshaNalluru Mar 31, 2024
a5c82ed
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 31, 2024
383f331
lock file
HarshaNalluru Mar 31, 2024
ee8228b
rush update --full
HarshaNalluru Mar 31, 2024
9c4ae23
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Apr 1, 2024
d0582e8
lock file
HarshaNalluru Apr 1, 2024
9b35527
rush update --full
HarshaNalluru Apr 1, 2024
cc381c7
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Apr 1, 2024
a4a73c4
lock file
HarshaNalluru Apr 1, 2024
871b186
remove @types/express
HarshaNalluru Apr 1, 2024
161b4d6
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Apr 1, 2024
7b1a01c
lock file with rush update --full
HarshaNalluru Apr 1, 2024
61db6e9
fix glob pattern for windows
HarshaNalluru Apr 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,465 changes: 1,056 additions & 409 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions sdk/test-utils/recorder/.tshy/browser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
],
"exclude": [],
"compilerOptions": {
"outDir": "../.tshy-build/browser"
}
}
8 changes: 8 additions & 0 deletions sdk/test-utils/recorder/.tshy/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../src",
"module": "nodenext",
"moduleResolution": "nodenext"
}
}
16 changes: 16 additions & 0 deletions sdk/test-utils/recorder/.tshy/commonjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx"
],
"exclude": [
"../src/**/*.mts",
"../src/utils/encoding-browser.mts",
"../src/utils/relativePathCalculator-browser.mts"
],
"compilerOptions": {
"outDir": "../.tshy-build/commonjs"
}
}
15 changes: 15 additions & 0 deletions sdk/test-utils/recorder/.tshy/esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
],
"exclude": [
".././src/utils/encoding-browser.mts",
".././src/utils/relativePathCalculator-browser.mts"
],
"compilerOptions": {
"outDir": "../.tshy-build/esm"
}
}
15 changes: 15 additions & 0 deletions sdk/test-utils/recorder/.tshy/react-native.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
],
"exclude": [
".././src/utils/encoding-browser.mts",
".././src/utils/relativePathCalculator-browser.mts"
],
"compilerOptions": {
"outDir": "../.tshy-build/react-native"
}
}
26 changes: 26 additions & 0 deletions sdk/test-utils/recorder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Release History

## 4.0.0 (Unreleased)

### Features Added

- Enhanced the `addSanitizers` method and `SanitizerOptions` options bag by exposing the following sanitizer types for more flexible usage:

- `FindReplaceSanitizer`: A sanitizer that finds and replaces specified strings.
- `RegexSanitizer`: A sanitizer that uses regular expressions for pattern matching and replacement.
- `StringSanitizer`: A sanitizer that handles string-based sanitization tasks.
- `HeaderSanitizer`: A sanitizer specifically designed for handling HTTP headers.
- `ConnectionStringSanitizer`: A sanitizer that securely handles connection strings.
- `RemoveHeaderSanitizer`: A sanitizer that removes specified headers from HTTP requests or responses.

This update aims to provide users with a more comprehensive and customizable sanitization process.

### Breaking Changes

- The `@azure-tools/[email protected]` package now supports `vitest` and `playwright` (stops support for `mocha` and `karma`), employs `process.env` in both Node and browser environments. This aligns with the latest testing frameworks and provides improved testing capabilities.

- The package has been simplified by removing the `dotenv` dependency and the `karma.conf` file, env shims for the browser. This streamlines the package dependencies and configuration files, respectively.
- These changes introduce a new `env` strategy for all SDKs once they migrate to ESM and depend on `@azure-tools/test-recorder` version 4, as we employ `process.env` through vitest to access environment variables in both Node and browser environments.

### Bugs Fixed

### Other Changes

## 3.1.0 (2023-03-14)

### Features Added
Expand Down
124 changes: 0 additions & 124 deletions sdk/test-utils/recorder/karma.conf.js

This file was deleted.

101 changes: 61 additions & 40 deletions sdk/test-utils/recorder/package.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
{
"name": "@azure-tools/test-recorder",
"version": "3.1.0",
"version": "4.0.0",
"sdk-type": "utility",
"description": "This library provides interfaces and helper methods to provide recording and playback capabilities for the tests in Azure JS/TS SDKs",
"main": "dist/index.js",
"module": "dist-esm/src/index.js",
"types": "./types/src/index.d.ts",
"browser": {
"./dist-esm/src/utils/relativePathCalculator.js": "./dist-esm/src/utils/relativePathCalculator.browser.js",
"./dist-esm/src/utils/env.js": "./dist-esm/src/utils/env.browser.js",
"./dist-esm/src/utils/encoding.js": "./dist-esm/src/utils/encoding.browser.js",
"./dist-esm/test/utils/server.js": "./dist-esm/test/utils/server.browser.js"
},
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts",
"scripts": {
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build:browser": "echo skipped",
"build:node": "tsc -p . && dev-tool run bundle",
"build:node": "tshy && npm run build:test",
"build:samples": "echo Skipped.",
"build:test": "tsc -p . && dev-tool run bundle",
"build": "npm run clean && tsc -p . && dev-tool run bundle",
"build:test": "tshy && dev-tool run build-test",
"build": "npm run clean && npm run build:test",
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf --glob dist dist-esm test-dist typings *.tgz *.log",
"extract-api": "echo skipped",
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "concurrently \"npm run tests:server\" \"npm run test:browser-with-proxy\" --kill-others --success first",
"integration-test:node": "concurrently \"npm run tests:server\" \"npm run test:node-with-proxy\" --kill-others --success first",
"test:node-with-proxy": "dev-tool run test:node-ts-input -- --timeout 1200000 \"test/*.spec.ts\"",
"test:browser-with-proxy": "dev-tool run test:browser",
"test:node-with-proxy": "dev-tool run test:vitest",
"test:browser-with-proxy": "dev-tool run test:vitest --browser",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"tests:server": "cross-env TS_NODE_COMPILER_OPTIONS=\"{\\\"module\\\": \\\"commonjs\\\"}\" ts-node test/utils/server.ts",
"tests:server": "node server.mjs",
"lint:fix": "eslint --no-eslintrc -c ../../.eslintrc.internal.json package.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint --no-eslintrc -c ../../.eslintrc.internal.json package.json src test --ext .ts",
"pack": "npm pack 2>&1",
Expand Down Expand Up @@ -65,40 +58,68 @@
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/test-utils/recorder/",
"sideEffects": false,
"dependencies": {
"@azure/core-rest-pipeline": "^1.13.0",
"@azure/core-auth": "^1.3.2",
"@azure/core-client": "^1.0.0",
"@azure/core-rest-pipeline": "^1.13.0",
"@azure/core-util": "^1.6.1",
"@azure/logger": "^1.0.0"
},
"devDependencies": {
"@azure/core-client": "^1.0.0",
"@azure-tools/vite-plugin-browser-test-map": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@types/express": "^4.16.0",
"@microsoft/api-extractor": "^7.40.3",
"@types/fs-extra": "^8.0.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^10.0.0",
"@types/node": "^18.0.0",
"c8": "^9.1.0",
"chai": "^4.2.0",
"@vitest/browser": "^1.4.0",
"@vitest/coverage-istanbul": "^1.4.0",
"concurrently": "^8.2.0",
"cross-env": "7.0.3",
"dotenv": "^16.0.0",
"eslint": "^8.0.0",
"express": "^4.16.3",
"karma": "^6.2.0",
"karma-chrome-launcher": "^3.0.0",
"karma-coverage": "^2.0.0",
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^1.1.0",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"eslint": "^8.56.0",
"express": "^4.19.2",
"loupe": "^3.1.0",
"playwright": "^1.41.2",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"tslib": "^2.2.0",
"ts-node": "^10.0.0",
"typescript": "~5.3.3"
}
"tshy": "^1.13.0",
"tslib": "^2.6.2",
"typescript": "~5.3.3",
"vitest": "^1.4.0"
},
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
},
"dialects": [
"esm",
"commonjs"
],
"esmDialects": [
"browser",
"react-native"
]
},
"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"
}
}
},
"type": "module"
}
19 changes: 13 additions & 6 deletions sdk/test-utils/recorder/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export { Recorder } from "./recorder";
export { relativeRecordingsPath } from "./utils/relativePathCalculator";
export { Recorder } from "./recorder.js";
export { relativeRecordingsPath } from "./utils/relativePathCalculator.js";
export {
SanitizerOptions,
RecorderStartOptions,
Expand All @@ -12,7 +12,14 @@ export {
assertEnvironmentVariable,
setEnvironmentVariables,
testPollingOptions,
} from "./utils/utils";
export { env } from "./utils/env";
export { delay } from "./utils/delay";
export { CustomMatcherOptions } from "./matcher";
FindReplaceSanitizer,
RegexSanitizer,
StringSanitizer,
HeaderSanitizer,
ConnectionStringSanitizer,
RemoveHeaderSanitizer,
} from "./utils/utils.js";
export { delay } from "./utils/delay.js";
export { env } from "./utils/env.js";
export { CustomMatcherOptions } from "./matcher.js";
export { TestInfo, VitestTestContext } from "./testInfo.js";
Loading