Skip to content

Commit 70e7886

Browse files
committed
chore: tests for scoped package
1 parent 0693c35 commit 70e7886

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

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')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import os
2+
import unittest
3+
4+
from core.base_test.tns_run_test import TnsRunTest
5+
from core.enums.os_type import OSType
6+
from core.enums.platform_type import Platform
7+
from core.settings import Settings
8+
from core.utils.npm import Npm
9+
from data.changes import Changes
10+
from data.const import Colors
11+
from data.templates import Template
12+
from products.nativescript.run_type import RunType
13+
from products.nativescript.tns import Tns
14+
from products.nativescript.tns_logs import TnsLogs
15+
16+
17+
class TestRunWithScopePackageOnly(TnsRunTest):
18+
app_name = Settings.AppName.DEFAULT
19+
app_path = os.path.join(Settings.TEST_RUN_HOME, Settings.AppName.DEFAULT)
20+
@classmethod
21+
def setUpClass(cls):
22+
TnsRunTest.setUpClass()
23+
24+
# Create app
25+
Tns.create(app_name=cls.app_name, template=Template.HELLO_WORLD_TS.local_package, update=True)
26+
Npm.uninstall(package='tns-core-modules', option='--save', folder=cls.app_path)
27+
Npm.install(package=Settings.Packages.NATIVESCRIPT_CORE, option='--save --save-exact', folder=cls.app_path)
28+
Tns.platform_add_android(app_name=cls.app_name, framework_path=Settings.Android.FRAMEWORK_PATH)
29+
if Settings.HOST_OS is OSType.OSX:
30+
Tns.platform_add_ios(app_name=cls.app_name, framework_path=Settings.IOS.FRAMEWORK_PATH)
31+
32+
def setUp(self):
33+
TnsRunTest.setUp(self)
34+
35+
@classmethod
36+
def tearDownClass(cls):
37+
TnsRunTest.tearDownClass()
38+
39+
def test_100_run_android(self):
40+
self.run_app(Platform.ANDROID, self.emu)
41+
42+
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
43+
def test_100_run_ios(self):
44+
self.run_app(Platform.IOS, self.sim)
45+
46+
def run_app(self, platform, device):
47+
result = Tns.run(app_name=self.app_name, platform=platform, emulator=True, wait=False)
48+
strings = TnsLogs.run_messages(app_name=self.app_name, platform=platform, run_type=RunType.UNKNOWN,
49+
device=device)
50+
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=240)
51+
52+
# Verify it looks properly
53+
device.wait_for_text(text=Changes.TSHelloWord.TS.old_text)
54+
device.wait_for_text(text=Changes.TSHelloWord.XML.old_text)
55+
blue_count = device.get_pixels_by_color(color=Colors.LIGHT_BLUE)
56+
assert blue_count > 100, 'Failed to find blue color on {0}'.format(device.name)

0 commit comments

Comments
 (0)