diff --git a/.ado/stages.yml b/.ado/stages.yml index 91520faffdd..5a04f46b0d2 100644 --- a/.ado/stages.yml +++ b/.ado/stages.yml @@ -50,10 +50,10 @@ stages: buildEnvironment: ${{ parameters.buildEnvironment }} AgentPool: ${{ parameters.AgentPool }} - # - template: jobs/node-tests.yml - # parameters: - # buildEnvironment: ${{ parameters.buildEnvironment }} - # AgentPool: ${{ parameters.AgentPool }} + - template: jobs/node-tests.yml + parameters: + buildEnvironment: ${{ parameters.buildEnvironment }} + AgentPool: ${{ parameters.AgentPool }} - template: jobs/macos-tests.yml diff --git a/change/@react-native-windows-cli-274e77bd-2b03-4168-953e-6ad619e120e3.json b/change/@react-native-windows-cli-274e77bd-2b03-4168-953e-6ad619e120e3.json new file mode 100644 index 00000000000..11dfc0a341a --- /dev/null +++ b/change/@react-native-windows-cli-274e77bd-2b03-4168-953e-6ad619e120e3.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Fix broken CLI tests", + "packageName": "@react-native-windows/cli", + "email": "jthysell@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/@react-native-windows/cli/src/commands/config/configUtils.ts b/packages/@react-native-windows/cli/src/commands/config/configUtils.ts index 6634635a4bd..cee84408dcb 100644 --- a/packages/@react-native-windows/cli/src/commands/config/configUtils.ts +++ b/packages/@react-native-windows/cli/src/commands/config/configUtils.ts @@ -533,7 +533,10 @@ export function getRnwConfig( root: string, projectFile: string, ): Record | undefined { - const pkgJson = require(path.join(root, 'package.json')); + const pkgPath = path.join(root, 'package.json'); + const pkgJson = fs.existsSync(pkgPath) + ? require(path.join(root, 'package.json')) + : {}; const config: Record = pkgJson['react-native-windows'] ?? {}; diff --git a/packages/@react-native-windows/cli/src/e2etest/__snapshots__/dependencyConfig.test.ts.snap b/packages/@react-native-windows/cli/src/e2etest/__snapshots__/dependencyConfig.test.ts.snap index 47a99578256..2c9383c581e 100644 --- a/packages/@react-native-windows/cli/src/e2etest/__snapshots__/dependencyConfig.test.ts.snap +++ b/packages/@react-native-windows/cli/src/e2etest/__snapshots__/dependencyConfig.test.ts.snap @@ -77,6 +77,11 @@ exports[`dependencyConfig - SimpleCSharpLib (Ignore react-native.config.js) 1`] "projectName": "SimpleCSharpLib", }, ], + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cs-lib", + }, + }, "solutionFile": "SimpleCSharpLib.sln", "sourceDir": "windows", } @@ -107,6 +112,11 @@ exports[`dependencyConfig - SimpleCSharpLib (Use react-native.config.js) 1`] = ` "projectName": "SimpleCSharpLib", }, ], + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cs-lib", + }, + }, "solutionFile": "SimpleCSharpLib.sln", "sourceDir": "windows", } @@ -165,6 +175,11 @@ exports[`dependencyConfig - SimpleCppLib (Ignore react-native.config.js) 1`] = ` "projectName": "SimpleCppLib", }, ], + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cpp-lib", + }, + }, "solutionFile": "SimpleCppLib.sln", "sourceDir": "windows", } @@ -195,6 +210,11 @@ exports[`dependencyConfig - SimpleCppLib (Use react-native.config.js) 1`] = ` "projectName": "SimpleCppLib", }, ], + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cpp-lib", + }, + }, "solutionFile": "SimpleCppLib.sln", "sourceDir": "windows", } diff --git a/packages/@react-native-windows/cli/src/e2etest/__snapshots__/projectConfig.test.ts.snap b/packages/@react-native-windows/cli/src/e2etest/__snapshots__/projectConfig.test.ts.snap index ca21961c233..b130ebf649b 100644 --- a/packages/@react-native-windows/cli/src/e2etest/__snapshots__/projectConfig.test.ts.snap +++ b/packages/@react-native-windows/cli/src/e2etest/__snapshots__/projectConfig.test.ts.snap @@ -10,6 +10,9 @@ exports[`projectConfig - MissingProjectFilesApp (Ignore react-native.config.js) "project": { "projectFile": "Error: No app project file found, please specify in react-native.config.", }, + "rnwConfig": { + "init-windows": {}, + }, "solutionFile": "Error: No app solution file found, please specify in react-native.config.", "sourceDir": "windows", } @@ -21,6 +24,9 @@ exports[`projectConfig - MissingProjectFilesApp (Use react-native.config.js) 1`] "project": { "projectFile": "Error: Project is required but not specified in react-native.config.", }, + "rnwConfig": { + "init-windows": {}, + }, "solutionFile": "Error: Solution file is required but not specified in react-native.config.", "sourceDir": "windows", } @@ -32,7 +38,6 @@ exports[`projectConfig - SimpleCSharpApp (Ignore react-native.config.js) 1`] = ` "ReactExperimentalFeaturesSet": "true", "UseExperimentalNuget": "false", "UseHermes": "false", - "UseWinUI3": "false", }, "folder": StringContaining "SimpleCSharpApp", "project": { @@ -41,6 +46,11 @@ exports[`projectConfig - SimpleCSharpApp (Ignore react-native.config.js) 1`] = ` "projectLang": "cs", "projectName": "SimpleCSharpApp", }, + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cs-app", + }, + }, "solutionFile": "SimpleCSharpApp.sln", "sourceDir": "windows", } @@ -52,7 +62,6 @@ exports[`projectConfig - SimpleCSharpApp (Use react-native.config.js) 1`] = ` "ReactExperimentalFeaturesSet": "true", "UseExperimentalNuget": "false", "UseHermes": "false", - "UseWinUI3": "false", }, "folder": StringContaining "SimpleCSharpApp", "project": { @@ -61,6 +70,11 @@ exports[`projectConfig - SimpleCSharpApp (Use react-native.config.js) 1`] = ` "projectLang": "cs", "projectName": "SimpleCSharpApp", }, + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cs-app", + }, + }, "solutionFile": "SimpleCSharpApp.sln", "sourceDir": "windows", } @@ -72,7 +86,6 @@ exports[`projectConfig - SimpleCppApp (Ignore react-native.config.js) 1`] = ` "ReactExperimentalFeaturesSet": "true", "UseExperimentalNuget": "false", "UseHermes": "false", - "UseWinUI3": "false", }, "folder": StringContaining "SimpleCppApp", "project": { @@ -81,6 +94,11 @@ exports[`projectConfig - SimpleCppApp (Ignore react-native.config.js) 1`] = ` "projectLang": "cpp", "projectName": "SimpleCppApp", }, + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cpp-app", + }, + }, "solutionFile": "SimpleCppApp.sln", "sourceDir": "windows", } @@ -92,7 +110,6 @@ exports[`projectConfig - SimpleCppApp (Use react-native.config.js) 1`] = ` "ReactExperimentalFeaturesSet": "true", "UseExperimentalNuget": "false", "UseHermes": "false", - "UseWinUI3": "false", }, "folder": StringContaining "SimpleCppApp", "project": { @@ -101,6 +118,11 @@ exports[`projectConfig - SimpleCppApp (Use react-native.config.js) 1`] = ` "projectLang": "cpp", "projectName": "SimpleCppApp", }, + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cpp-app", + }, + }, "solutionFile": "SimpleCppApp.sln", "sourceDir": "windows", } @@ -112,7 +134,6 @@ exports[`projectConfig - WithExperimentalNuget (Ignore react-native.config.js) 1 "ReactExperimentalFeaturesSet": "true", "UseExperimentalNuget": "true", "UseHermes": "false", - "UseWinUI3": "false", }, "folder": StringContaining "WithExperimentalNuget", "project": { @@ -121,6 +142,11 @@ exports[`projectConfig - WithExperimentalNuget (Ignore react-native.config.js) 1 "projectLang": "cpp", "projectName": "WithExperimentalNuGet", }, + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cpp-app", + }, + }, "solutionFile": "WithExperimentalNuGet.sln", "sourceDir": "windows", } @@ -132,7 +158,6 @@ exports[`projectConfig - WithExperimentalNuget (Use react-native.config.js) 1`] "ReactExperimentalFeaturesSet": "true", "UseExperimentalNuget": "true", "UseHermes": "false", - "UseWinUI3": "false", }, "folder": StringContaining "WithExperimentalNuget", "project": { @@ -141,6 +166,11 @@ exports[`projectConfig - WithExperimentalNuget (Use react-native.config.js) 1`] "projectLang": "cpp", "projectName": "WithExperimentalNuGet", }, + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cpp-app", + }, + }, "solutionFile": "WithExperimentalNuGet.sln", "sourceDir": "windows", } @@ -152,7 +182,6 @@ exports[`projectConfig - WithHermes (Ignore react-native.config.js) 1`] = ` "ReactExperimentalFeaturesSet": "true", "UseExperimentalNuget": "false", "UseHermes": "true", - "UseWinUI3": "false", }, "folder": StringContaining "WithHermes", "project": { @@ -161,6 +190,11 @@ exports[`projectConfig - WithHermes (Ignore react-native.config.js) 1`] = ` "projectLang": "cpp", "projectName": "WithHermes", }, + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cpp-app", + }, + }, "solutionFile": "WithHermes.sln", "sourceDir": "windows", } @@ -172,7 +206,6 @@ exports[`projectConfig - WithHermes (Use react-native.config.js) 1`] = ` "ReactExperimentalFeaturesSet": "true", "UseExperimentalNuget": "false", "UseHermes": "true", - "UseWinUI3": "false", }, "folder": StringContaining "WithHermes", "project": { @@ -181,6 +214,11 @@ exports[`projectConfig - WithHermes (Use react-native.config.js) 1`] = ` "projectLang": "cpp", "projectName": "WithHermes", }, + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cpp-app", + }, + }, "solutionFile": "WithHermes.sln", "sourceDir": "windows", } @@ -197,6 +235,9 @@ exports[`projectConfig - WithIndirectDependency (Ignore react-native.config.js) "project": { "projectFile": "Error: Too many app project files found, please specify in react-native.config.", }, + "rnwConfig": { + "init-windows": {}, + }, "solutionFile": "WithIndirectDependency.sln", "sourceDir": "windows", } @@ -216,6 +257,11 @@ exports[`projectConfig - WithIndirectDependency (Use react-native.config.js) 1`] "projectLang": "cpp", "projectName": "WithIndirectDependency", }, + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cpp-app", + }, + }, "solutionFile": "WithIndirectDependency.sln", "sourceDir": "windows", "useWinUI3": false, @@ -228,7 +274,6 @@ exports[`projectConfig - WithWinUI3 (Ignore react-native.config.js) 1`] = ` "ReactExperimentalFeaturesSet": "true", "UseExperimentalNuget": "false", "UseHermes": "false", - "UseWinUI3": "true", }, "folder": StringContaining "WithWinUI3", "project": { @@ -237,6 +282,11 @@ exports[`projectConfig - WithWinUI3 (Ignore react-native.config.js) 1`] = ` "projectLang": "cpp", "projectName": "WithWinUI3", }, + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cpp-app", + }, + }, "solutionFile": "WithWinUI3.sln", "sourceDir": "windows", } @@ -248,7 +298,6 @@ exports[`projectConfig - WithWinUI3 (Use react-native.config.js) 1`] = ` "ReactExperimentalFeaturesSet": "true", "UseExperimentalNuget": "false", "UseHermes": "false", - "UseWinUI3": "true", }, "folder": StringContaining "WithWinUI3", "project": { @@ -257,6 +306,11 @@ exports[`projectConfig - WithWinUI3 (Use react-native.config.js) 1`] = ` "projectLang": "cpp", "projectName": "WithWinUI3", }, + "rnwConfig": { + "init-windows": { + "template": "old/uwp-cpp-app", + }, + }, "solutionFile": "WithWinUI3.sln", "sourceDir": "windows", } @@ -281,14 +335,6 @@ exports[`useWinUI3=true in react-native.config.js, UseWinUI3=false in Experiment --> false - - false -