From a6b5a3614a447e69fd474b74cf935e7e2b45fdd8 Mon Sep 17 00:00:00 2001 From: Maor Leger Date: Thu, 14 Nov 2024 14:18:53 -0800 Subject: [PATCH] [identity] Various test fixes (#31764) A few fixes as a result of the identity ESM migration: 1. Missing `ctx` parameter that's now fixed 2. Default vitest config excludes managed identity tests. Adding a separate vitest config for managed identity test runs fixes this --- sdk/identity/identity/package.json | 2 +- .../integration/node/azureKubernetesTest.spec.ts | 2 +- .../public/node/multiTenantAuthentication.spec.ts | 4 ++-- .../identity/vitest.managed-identity.config.ts | 14 ++++++++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 sdk/identity/identity/vitest.managed-identity.config.ts diff --git a/sdk/identity/identity/package.json b/sdk/identity/identity/package.json index 1e65c63921bd..2ea548c66903 100644 --- a/sdk/identity/identity/package.json +++ b/sdk/identity/identity/package.json @@ -29,7 +29,7 @@ "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", "integration-test": "npm run integration-test:node && npm run integration-test:browser", "integration-test:browser": "echo skipped", - "integration-test:managed-identity": "dev-tool run test:vitest -- --test-timeout 180000 'test/integration/**/*.spec.ts'", + "integration-test:managed-identity": "dev-tool run test:vitest -- --test-timeout 180000 --config ./vitest.managed-identity.config.ts", "integration-test:node": "dev-tool run test:vitest -- --test-timeout 180000 'test/public/node/*.spec.ts' 'test/internal/node/*.spec.ts'", "lint": "eslint package.json api-extractor.json src test", "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", diff --git a/sdk/identity/identity/test/integration/node/azureKubernetesTest.spec.ts b/sdk/identity/identity/test/integration/node/azureKubernetesTest.spec.ts index 2f4a241b0f86..51b0c634ec6f 100644 --- a/sdk/identity/identity/test/integration/node/azureKubernetesTest.spec.ts +++ b/sdk/identity/identity/test/integration/node/azureKubernetesTest.spec.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { execSync } from "child_process"; import { isLiveMode } from "@azure-tools/test-recorder"; -import { describe, it, assert, expect, vi, beforeEach, afterEach, beforeAll } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; describe("Azure Kubernetes Integration test", function () { let podOutput: string; diff --git a/sdk/identity/identity/test/public/node/multiTenantAuthentication.spec.ts b/sdk/identity/identity/test/public/node/multiTenantAuthentication.spec.ts index 091a13d37be1..c3e542ee85a0 100644 --- a/sdk/identity/identity/test/public/node/multiTenantAuthentication.spec.ts +++ b/sdk/identity/identity/test/public/node/multiTenantAuthentication.spec.ts @@ -8,7 +8,7 @@ import { env } from "@azure-tools/test-recorder"; import { createHttpHeaders, createPipelineRequest } from "@azure/core-rest-pipeline"; import { ClientSecretCredential } from "../../../src/credentials/clientSecretCredential.js"; import { IdentityClient } from "../../../src/client/identityClient.js"; -import { describe, it, assert, expect, vi, beforeEach, afterEach } from "vitest"; +import { describe, it, assert, beforeEach, afterEach } from "vitest"; describe("MultiTenantAuthentication", function () { let cleanup: MsalTestCleanup; @@ -24,7 +24,7 @@ describe("MultiTenantAuthentication", function () { await cleanup(); }); - it("supports calling graph with client secret", async function () { + it("supports calling graph with client secret", async function (ctx) { const [tenantId, clientId, clientSecret] = [ env.AZURE_IDENTITY_MULTI_TENANT_TENANT_ID, env.AZURE_IDENTITY_MULTI_TENANT_CLIENT_ID, diff --git a/sdk/identity/identity/vitest.managed-identity.config.ts b/sdk/identity/identity/vitest.managed-identity.config.ts new file mode 100644 index 000000000000..ab40c26ebe73 --- /dev/null +++ b/sdk/identity/identity/vitest.managed-identity.config.ts @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig, mergeConfig } from "vitest/config"; +import viteConfig from "../../../vitest.shared.config.ts"; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + include: ["test/integration/**/*.spec.ts"], + }, + }), +);