Skip to content

Commit f943fb0

Browse files
test(react-native-cli): check that the built artifact exists after building
1 parent be78e79 commit f943fb0

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

test/react-native-cli/features/build-app-tests/build-android-app.feature

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ Feature: Tests for building a React Native app (for Android only) that was initi
1010
And the sourcemap payload field "apiKey" equals "1234567890ABCDEF1234567890ABCDEF"
1111
And the sourcemap payload field "platform" equals "android"
1212
And the sourcemap payload field "overwrite" equals "true"
13+
14+
And the APK file exists

test/react-native-cli/features/build-app-tests/build-ios-app.feature

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ Feature: Tests for building a React Native app (for iOS only) that was initializ
1313

1414
# Re-archive and export an IPA that can be used for subsequent tests
1515
Then I export the iOS archive
16+
And the IPA file exists
1617

test/react-native-cli/features/steps/steps.rb

+13-21
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
require 'rexml/document'
22
require 'securerandom'
33

4-
fixtures = Dir["#{__dir__}/../fixtures/rn0_*"].map { |dir| File.basename(dir) }.sort
54
current_fixture = ENV['RN_VERSION']
65
fixture_dir = "#{__dir__}/../../../react-native-cli/features/fixtures/generated/"
6+
generate_fixture_script = "#{__dir__}/../../../../scripts/generate-react-native-cli-fixture.js"
77

88
# if RCT_NEW_ARCH_ENABLED is set add new-arch/ to the fixture_dir
99
if ENV['RCT_NEW_ARCH_ENABLED'] == 'true' || ENV['RCT_NEW_ARCH_ENABLED'] == '1'
@@ -16,25 +16,8 @@
1616
step("I run the service '#{current_fixture}' interactively")
1717
end
1818

19-
def find_cli_helper_script
20-
# Handle both Dockerized and local Maze Runner executions
21-
script = 'generate-react-native-cli-fixture.js'
22-
possible_locations = %W[
23-
#{__dir__}/../../../../scripts/#{script}
24-
]
25-
path = possible_locations.find { |path| File.exist?(path) }
26-
if path.nil?
27-
raise <<~ERROR
28-
The React Native CLI helper script was not found in any of the expected locations:
29-
- #{possible_locations.join("\n -")}
30-
ERROR
31-
end
32-
path
33-
end
34-
3519
When('I build the Android app') do
36-
script_path = find_cli_helper_script
37-
$logger.info `node #{script_path}`
20+
$logger.info `node #{generate_fixture_script}`
3821

3922
# Change directory to fixture_dir
4023
Dir.chdir(fixture_dir) do
@@ -43,8 +26,7 @@ def find_cli_helper_script
4326
end
4427

4528
When('I build the iOS app') do
46-
script_path = find_cli_helper_script
47-
$logger.info `node #{script_path}`
29+
$logger.info `node #{generate_fixture_script}`
4830

4931
# Change directory to fixture_dir
5032
Dir.chdir(fixture_dir) do
@@ -57,6 +39,16 @@ def find_cli_helper_script
5739
$logger.info `node -e 'require("#{script_path}").buildIPA("#{fixture_dir}")'`
5840
end
5941

42+
When('the APK file exists') do
43+
apk_path = "#{fixture_dir}/reactnative.apk"
44+
Maze.check.true(File.exist?(apk_path))
45+
end
46+
47+
When('the IPA file exists') do
48+
ipa_path = "#{fixture_dir}/output/reactnative.ipa"
49+
Maze.check.true(File.exist?(ipa_path))
50+
end
51+
6052
def parse_package_json
6153
stdout_lines = Maze::Runner.interactive_session.stdout_lines
6254
length_before = stdout_lines.length

0 commit comments

Comments
 (0)