A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.
JavaScript claude-code-pluginclaude-code-skillscode-appsgithub-copilot-pluginpower-appspower-pagespower-platform
[Pages] Stub child_process.execSync directly in validation-helpers test (#133)
Priyanshu Agrawal48e49c475749
diff --git a/plugins/power-pages/scripts/tests/validation-helpers.test.js b/plugins/power-pages/scripts/tests/validation-helpers.test.jsindex 5e446ed0e..bcd1ec79b 100644--- a/plugins/power-pages/scripts/tests/validation-helpers.test.js+++ b/plugins/power-pages/scripts/tests/validation-helpers.test.js@@ -1,39 +1,31 @@const test = require('node:test');const assert = require('node:assert/strict');const path = require('path');+const childProcess = require('child_process');const helpersPath = path.join(__dirname, '..', 'lib', 'validation-helpers.js');-const childProcessId = require.resolve('child_process');-test('getAuthToken passes --allow-no-subscriptions to az', () => {- const originalChildProcess = require.cache[childProcessId];+test('getAuthToken passes --allow-no-subscriptions to az', (t) => {+ const originalExecSync = childProcess.execSync;let capturedCommand = null;- require.cache[childProcessId] = {- id: childProcessId,- filename: childProcessId,- loaded: true,- exports: {- execSync: (command, options) => {- capturedCommand = command;- const out = 'fake-token-value\n';- return options && options.encoding ? out : Buffer.from(out);- },- },+ childProcess.execSync = (command, options) => {+ capturedCommand = command;+ const out = 'fake-token-value\n';+ return options && options.encoding ? out : Buffer.from(out);};delete require.cache[require.resolve(helpersPath)];- try {- const { getAuthToken } = require(helpersPath);- const token = getAuthToken('https://example.crm.dynamics.com');-- assert.equal(token, 'fake-token-value');- assert.match(capturedCommand, /^az account get-access-token /);- assert.match(capturedCommand, /--allow-no-subscriptions/);- assert.match(capturedCommand, /--resource "https:\/\/example\.crm\.dynamics\.com"/);- } finally {- if (originalChildProcess) require.cache[childProcessId] = originalChildProcess;- else delete require.cache[childProcessId];+ t.after(() => {+ childProcess.execSync = originalExecSync;delete require.cache[require.resolve(helpersPath)];- }+ });++ const { getAuthToken } = require(helpersPath);+ const token = getAuthToken('https://example.crm.dynamics.com');++ assert.equal(token, 'fake-token-value');+ assert.match(capturedCommand, /^az account get-access-token /);+ assert.match(capturedCommand, /--allow-no-subscriptions/);+ assert.match(capturedCommand, /--resource "https:\/\/example\.crm\.dynamics\.com"/);});