Skip to content

Commit c0bfea7

Browse files
authored
fix: React Native Windows E2E test app (#726)
1 parent d4f97a0 commit c0bfea7

32 files changed

+4600
-3811
lines changed

azure-pipelines.yml

+16-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ steps:
1616
submodules: false
1717
persistCredentials: false
1818

19+
- task: PowerShell@2
20+
displayName: Install Visual Studio dependencies
21+
inputs:
22+
targetType: filePath
23+
filePath: fixtures/react_native_windows_e2e_app/scripts/Install-VsFeatures.ps1
24+
arguments:
25+
-Components "Microsoft.VisualStudio.ComponentGroup.UWP.VC.v141"
26+
-Cleanup:$true
27+
28+
- task: PowerShell@2
29+
displayName: List Visual Studio Components
30+
inputs:
31+
targetType: filePath
32+
filePath: fixtures/react_native_windows_e2e_app/scripts/VSComponentList.ps1
33+
1934
- task: CmdLine@2
2035
displayName: Install Haul dependencies
2136
inputs:
@@ -36,7 +51,7 @@ steps:
3651
- task: CmdLine@2
3752
displayName: run-windows
3853
inputs:
39-
script: yarn run start:app --logging --force
54+
script: yarn run start:app --logging
4055
workingDirectory: fixtures/react_native_windows_e2e_app
4156

4257
- task: PowerShell@2

fixtures/react_native_windows_e2e_app/.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
project.xcworkspace
2423

2524
# Android/IntelliJ
2625
#
@@ -40,6 +39,7 @@ yarn-error.log
4039
buck-out/
4140
\.buckd/
4241
*.keystore
42+
!debug.keystore
4343

4444
# fastlane
4545
#
@@ -54,3 +54,7 @@ buck-out/
5454

5555
# Bundle artifact
5656
*.jsbundle
57+
58+
# MSBuild artifact
59+
msbuild.binlog
60+
msbuild.ProjectImports.zip

fixtures/react_native_windows_e2e_app/__tests__/appium.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import wd from 'wd';
22
import execa from 'execa';
33

4-
jest.setTimeout(60000);
4+
jest.setTimeout(80000);
55
const PORT = 4723;
66
const config = {
77
platformName: 'Windows',
@@ -12,7 +12,7 @@ let appiumServer = { cancel() {} };
1212

1313
beforeAll(async () => {
1414
appiumServer = execa.command('yarn run appium');
15-
await new Promise(resolve => setTimeout(resolve, 4000));
15+
await new Promise(resolve => setTimeout(resolve, 20000));
1616

1717
await driver.init({ ...config, app: 'Root' });
1818
await driver.sleep(2000);

fixtures/react_native_windows_e2e_app/package.json

+15-12
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,39 @@
33
"version": "0.0.1",
44
"private": true,
55
"scripts": {
6-
"start": "../../packages/haul-cli/bin/haul start",
6+
"prepare": "patch-package",
7+
"start": "node ../../packages/haul-cli/bin/haul.js start",
78
"test": "jest",
89
"build:bundle": "node ../../packages/haul-cli/bin/haul.js bundle --platform windows --dev true --bundle-output windows/RNWTestApp/Bundle/index.windows.bundle --assets-dest windows/RNWTestApp/Bundle",
9-
"start:app": "node_modules/.bin/react-native run-windows --arch x86 --no-packager"
10+
"start:app": "node_modules/.bin/react-native run-windows --arch x64 --no-packager"
1011
},
1112
"dependencies": {
1213
"apollo-cache-inmemory": "^1.6.3",
1314
"apollo-client": "^2.6.4",
1415
"apollo-link-http": "^1.5.16",
1516
"graphql": "^14.5.7",
1617
"graphql-tag": "^2.10.1",
17-
"patch-package": "^6.2.0",
1818
"postinstall-postinstall": "^2.0.0",
19-
"react": "16.10.1",
19+
"react": "16.9.0",
2020
"react-apollo": "^3.1.1",
21-
"react-native": "^0.60.0",
22-
"react-native-windows": "0.60.0-vnext.115",
21+
"react-native": "0.61.5",
22+
"react-native-windows": "^0.61.0-0",
2323
"rnpm-plugin-windows": "^0.3.5"
2424
},
2525
"devDependencies": {
26-
"@babel/core": "^7.6.0",
27-
"@babel/runtime": "^7.6.0",
26+
"@babel/core": "^7.9.6",
27+
"@babel/runtime": "^7.9.6",
2828
"appium": "^1.14.2",
29-
"babel-jest": "^24.9.0",
29+
"babel-jest": "^26.0.1",
3030
"execa": "^2.0.4",
31-
"jest": "^24.9.0",
32-
"metro-react-native-babel-preset": "^0.56.0",
31+
"jest": "^26.0.1",
32+
"metro-react-native-babel-preset": "^0.59.0",
33+
"patch-package": "^6.1.2",
34+
"postinstall-prepare": "^1.0.1",
35+
"react-test-renderer": "16.9.0",
3336
"wd": "^1.11.4"
3437
},
3538
"jest": {
3639
"preset": "react-native"
3740
}
38-
}
41+
}

fixtures/react_native_windows_e2e_app/patches/react-native-windows+0.60.0-vnext.16.patch

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/node_modules/react-native-windows/local-cli/runWindows/utils/deploy.js b/node_modules/react-native-windows/local-cli/runWindows/utils/deploy.js
2+
index 5bddc23..b04cc32 100644
3+
--- a/node_modules/react-native-windows/local-cli/runWindows/utils/deploy.js
4+
+++ b/node_modules/react-native-windows/local-cli/runWindows/utils/deploy.js
5+
@@ -80,7 +80,9 @@ function getAppxManifest(options) {
6+
const configuration = getBuildConfiguration(options);
7+
const appxManifestGlob = `windows/{*/bin/${
8+
options.arch
9+
- }/${configuration},${configuration}/*}/AppxManifest.xml`;
10+
+ }/${configuration},${
11+
+ options.arch
12+
+ }/${configuration}/*}/AppxManifest.xml`;
13+
const appxPath = glob.sync(path.join(options.root, appxManifestGlob))[0];
14+
15+
if (!appxPath) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
param (
2+
[Parameter(Mandatory=$true)]
3+
[string[]] $Components,
4+
5+
[uri] $InstallerUri = "https://download.visualstudio.microsoft.com/download/pr/c4fef23e-cc45-4836-9544-70e213134bc8/1ee5717e9a1e05015756dff77eb27d554a79a6db91f2716d836df368381af9a1/vs_Enterprise.exe",
6+
7+
[string] $VsInstaller = "${env:System_DefaultWorkingDirectory}\vs_Enterprise.exe",
8+
9+
[string] $VsInstallOutputDir = "${env:System_DefaultWorkingDirectory}\vs",
10+
11+
[System.IO.FileInfo] $VsInstallPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Enterprise",
12+
13+
[System.IO.FileInfo] $VsInstallerPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer",
14+
15+
[switch] $Collect = $false,
16+
17+
[switch] $Cleanup = $false,
18+
19+
[switch] $UseWebInstaller = $false
20+
)
21+
22+
$Components | ForEach-Object {
23+
$componentList += '--add', $_
24+
}
25+
26+
$LocalVsInstaller = "$VsInstallerPath\vs_installershell.exe"
27+
28+
$UseWebInstaller = $UseWebInstaller -or -not (Test-Path -Path "$LocalVsInstaller")
29+
30+
if ($UseWebInstaller) {
31+
Write-Host "Downloading web installer..."
32+
33+
Invoke-WebRequest -Method Get `
34+
-Uri $InstallerUri `
35+
-OutFile $VsInstaller
36+
37+
New-Item -ItemType directory -Path $VsInstallOutputDir
38+
39+
Write-Host "Running web installer to download requested components..."
40+
41+
Start-Process `
42+
-FilePath "$VsInstaller" `
43+
-ArgumentList ( `
44+
'--layout', "$VsInstallOutputDir",
45+
'--wait',
46+
'--norestart',
47+
'--quiet' + `
48+
$componentList
49+
) `
50+
-Wait `
51+
-PassThru
52+
53+
Write-Host "Running downloaded VS installer to add requested components..."
54+
55+
Start-Process `
56+
-FilePath "$VsInstallOutputDir\vs_Enterprise.exe" `
57+
-ArgumentList (
58+
'modify',
59+
'--installPath', "`"$VsInstallPath`"" ,
60+
'--wait',
61+
'--norestart',
62+
'--quiet' + `
63+
$componentList
64+
) `
65+
-Wait `
66+
-PassThru `
67+
-OutVariable returnCode
68+
69+
if ($Cleanup) {
70+
Write-Host "Cleaning up..."
71+
72+
Remove-Item -Path $VsInstaller
73+
Remove-Item -Path $VsInstallOutputDir -Recurse
74+
}
75+
76+
} else {
77+
Write-Host "Running local installer to add requested components..."
78+
79+
Start-Process `
80+
-FilePath "$LocalVsInstaller" `
81+
-ArgumentList (
82+
'modify',
83+
'--installPath', "`"$VsInstallPath`"" ,
84+
'--norestart',
85+
'--quiet' + `
86+
$componentList
87+
) `
88+
-Wait `
89+
-OutVariable returnCode
90+
}
91+
92+
if ($Collect) {
93+
Invoke-WebRequest -Method Get `
94+
-Uri 'https://download.microsoft.com/download/8/3/4/834E83F6-C377-4DCE-A757-69A418B6C6DF/Collect.exe' `
95+
-OutFile ${env:System_DefaultWorkingDirectory}\Collect.exe
96+
97+
# Should generate ${env:Temp}\vslogs.zip
98+
Start-Process `
99+
-FilePath "${env:System_DefaultWorkingDirectory}\Collect.exe" `
100+
-Wait `
101+
-PassThru
102+
103+
New-Item -ItemType Directory -Force ${env:System_DefaultWorkingDirectory}\vslogs
104+
Expand-Archive -Path ${env:TEMP}\vslogs.zip -DestinationPath ${env:System_DefaultWorkingDirectory}\vslogs\
105+
106+
Write-Host "VC versions after installation:"
107+
Get-ChildItem -Name "$VsInstallPath\VC\Tools\MSVC\"
108+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
$dir = $env:temp
2+
if ($env:Agent_TempDirectory -ne $null)
3+
{
4+
$dir = $env:Agent_TempDirectory
5+
}
6+
7+
$installerPath = 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\'
8+
$installationPath = . $installerPath\vswhere.exe -latest -property installationPath
9+
$vsconfig = "$dir\vsconfig"
10+
Write-Host "VSConfig will be at $vsconfig"
11+
12+
Invoke-WebRequest -Uri 'https://download.visualstudio.microsoft.com/download/pr/c4fef23e-cc45-4836-9544-70e213134bc8/1ee5717e9a1e05015756dff77eb27d554a79a6db91f2716d836df368381af9a1/vs_Enterprise.exe' -OutFile $dir\vs_enterprise.exe
13+
$p = Start-Process -PassThru $dir\vs_enterprise.exe -RedirectStandardError $dir\err -RedirectStandardOutput $dir\out -ArgumentList "export --installpath `"$installationPath`" --quiet --config $vsconfig"
14+
$p.WaitForExit()
15+
$x = [Datetime]::Now.AddSeconds(60)
16+
17+
do
18+
{
19+
Write-Host "Waiting for vsconfig file..."
20+
Sleep 5
21+
} while (!(Test-Path $vsconfig) -and ([datetime]::Now -lt $x))
22+
23+
Get-Content $dir\err
24+
Get-Content $dir\out
25+
Get-Content $vsconfig

fixtures/react_native_windows_e2e_app/windows/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@ packages/
8686
*.DotSettings
8787
.vs/
8888
*project.lock.json
89+
90+
#Files generated by the VS build
91+
**/Generated Files/**
92+

0 commit comments

Comments
 (0)