Skip to content

Commit b54ca69

Browse files
authored
Merge pull request #457 from NativeScript/test-for-issue-1089
test: for issue 1089
2 parents ffa4959 + 2cc992b commit b54ca69

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

Diff for: core/settings/Settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class Packages(object):
127127

128128
# Modules and Plugins
129129
MODULES = resolve_package(name='tns-core-modules', variable='tns_core_modules')
130+
NATIVESCRIPT_CORE = resolve_package(name='@nativescript/core', variable='tns_core_modules')
130131
ANGULAR = resolve_package(name='nativescript-angular', variable='nativescript_angular')
131132
WEBPACK = resolve_package(name='nativescript-dev-webpack', variable='nativescript_dev_webpack')
132133
TYPESCRIPT = resolve_package(name='nativescript-dev-typescript', variable='nativescript_dev_typescript')

Diff for: tests/cli/run/tests/test_run_scope_package_only.py

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# pylint: disable=redefined-builtin
2+
"""
3+
Tests for tns run on project without tns-core-modules package.
4+
See https://github.com/NativeScript/nativescript-dev-webpack/issues/1089
5+
"""
6+
import os
7+
8+
from parameterized import parameterized
9+
10+
from core.base_test.tns_run_test import TnsRunTest
11+
from core.enums.os_type import OSType
12+
from core.enums.platform_type import Platform
13+
from core.settings import Settings
14+
from core.utils.device.simctl import Simctl
15+
from core.utils.file_utils import Folder, File
16+
from core.utils.npm import Npm
17+
from data.templates import Template
18+
from products.nativescript.run_type import RunType
19+
from products.nativescript.tns import Tns
20+
from products.nativescript.tns_logs import TnsLogs
21+
22+
23+
# noinspection PyUnusedLocal
24+
# noinspection PyMethodMayBeStatic
25+
class TestRunWithScopedPackages(TnsRunTest):
26+
test_data = [
27+
[Template.HELLO_WORLD_JS.name.replace('template-', ''), Template.HELLO_WORLD_JS],
28+
[Template.HELLO_WORLD_TS.name.replace('template-', ''), Template.HELLO_WORLD_TS],
29+
[Template.HELLO_WORLD_NG.name.replace('template-', ''), Template.HELLO_WORLD_NG],
30+
[Template.MASTER_DETAIL_NG.name.replace('template-', ''), Template.MASTER_DETAIL_NG],
31+
]
32+
33+
@parameterized.expand(test_data)
34+
def test_scoped_package_only(self, app_name, template_info):
35+
TnsRunTest.setUp(self)
36+
37+
# Create app
38+
app_path = os.path.join(Settings.TEST_RUN_HOME, app_name)
39+
Tns.create(app_name=app_name, template=template_info.local_package, update=True)
40+
Npm.uninstall(package='tns-core-modules', option='--save', folder=app_path)
41+
Npm.install(package=Settings.Packages.NATIVESCRIPT_CORE, option='--save --save-exact', folder=app_path)
42+
43+
# Replace imports
44+
if template_info == Template.HELLO_WORLD_TS:
45+
files = File.find_by_extension(folder=os.path.join(app_path, 'app'), extension='ts')
46+
for file in files:
47+
File.replace(path=file, old_string='tns-core-modules', new_string='@nativescript/core', fail_safe=True)
48+
if template_info == Template.MASTER_DETAIL_NG:
49+
files = File.find_by_extension(folder=os.path.join(app_path, 'src'), extension='ts')
50+
for file in files:
51+
File.replace(path=file, old_string='tns-core-modules', new_string='@nativescript/core', fail_safe=True)
52+
53+
Tns.platform_add_android(app_name=app_name, framework_path=Settings.Android.FRAMEWORK_PATH)
54+
if Settings.HOST_OS is OSType.OSX:
55+
Tns.platform_add_ios(app_name=app_name, framework_path=Settings.IOS.FRAMEWORK_PATH)
56+
57+
# Run Android
58+
result = Tns.run_android(app_name=app_name, device=self.emu.id)
59+
strings = TnsLogs.run_messages(app_name=app_name, run_type=RunType.UNKNOWN, platform=Platform.ANDROID)
60+
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=300)
61+
for text in template_info.texts:
62+
self.emu.wait_for_text(text=text, timeout=60)
63+
64+
# Run iOS
65+
Tns.kill()
66+
if Settings.HOST_OS is OSType.OSX:
67+
Simctl.uninstall_all(simulator_info=self.sim)
68+
result = Tns.run_ios(app_name=app_name, device=self.sim.id)
69+
strings = TnsLogs.run_messages(app_name=app_name, run_type=RunType.UNKNOWN, platform=Platform.IOS)
70+
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=300)
71+
for text in template_info.texts:
72+
self.sim.wait_for_text(text=text, timeout=60)
73+
74+
# Cleanup
75+
Folder.clean(os.path.join(Settings.TEST_RUN_HOME, app_name))
76+
TnsRunTest.tearDown(self)

0 commit comments

Comments
 (0)