mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-09-19 17:12:47 +01:00
Move globalThis.crypto polyfill to fx.ts so it runs for all specs
This commit is contained in:
+8
-1
@@ -1,8 +1,15 @@
|
|||||||
import { DefaultAzureCredential } from "@azure/identity";
|
import { DefaultAzureCredential } from "@azure/identity";
|
||||||
import { Frame, Locator, Page, expect } from "@playwright/test";
|
import { Frame, Locator, Page, expect } from "@playwright/test";
|
||||||
import crypto from "crypto";
|
import crypto, { webcrypto } from "crypto";
|
||||||
import { TestContainerContext } from "./testData";
|
import { TestContainerContext } from "./testData";
|
||||||
|
|
||||||
|
// The @azure/cosmos client signs requests with globalThis.crypto (Web Crypto API).
|
||||||
|
// In Node.js >= 19 it's already available; only assign the polyfill for older versions.
|
||||||
|
// This lives in fx.ts (imported by every spec) so the polyfill always runs.
|
||||||
|
if (!globalThis.crypto) {
|
||||||
|
Object.defineProperty(globalThis, "crypto", { value: webcrypto, writable: true, configurable: true });
|
||||||
|
}
|
||||||
|
|
||||||
const RETRY_COUNT = 3;
|
const RETRY_COUNT = 3;
|
||||||
|
|
||||||
export interface TestNameOptions {
|
export interface TestNameOptions {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
JSONObject,
|
JSONObject,
|
||||||
} from "@azure/cosmos";
|
} from "@azure/cosmos";
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
import { webcrypto } from "node:crypto";
|
|
||||||
import {
|
import {
|
||||||
generateUniqueName,
|
generateUniqueName,
|
||||||
getAccountName,
|
getAccountName,
|
||||||
@@ -19,12 +18,6 @@ import {
|
|||||||
TestAccount,
|
TestAccount,
|
||||||
} from "./fx";
|
} from "./fx";
|
||||||
|
|
||||||
// In Node.js >= 19, globalThis.crypto is already available as a read-only getter.
|
|
||||||
// Only assign the polyfill for older versions.
|
|
||||||
if (!globalThis.crypto) {
|
|
||||||
Object.defineProperty(globalThis, "crypto", { value: webcrypto, writable: true, configurable: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TestItem {
|
export interface TestItem {
|
||||||
id: string;
|
id: string;
|
||||||
partitionKey: string;
|
partitionKey: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user