Skip to content

Commit 2135193

Browse files
authored
chore: assert error not in create output (#440)
* chore: assert error not in create output - Assert "Error:" not in tns create output - Assert exit code - Add missing docs for params * chore: fix lint error - Fix lint error - Fix `test_201_create_project_with_local_directory_template` in cases tests are executed from fodler different than project root
1 parent ce64e23 commit 2135193

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

products/nativescript/tns.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
from core.log.log import Log
1111
from core.settings import Settings
1212
from core.utils.file_utils import Folder, File
13+
from core.utils.json_utils import JsonUtils
1314
from core.utils.npm import Npm
1415
from core.utils.process import Process
1516
from core.utils.run import run
16-
from core.utils.json_utils import JsonUtils
1717
from products.nativescript.app import App
1818
from products.nativescript.tns_assert import TnsAssert
1919
from products.nativescript.tns_logs import TnsLogs
@@ -47,6 +47,8 @@ def exec_command(command, cwd=Settings.TEST_RUN_HOME, platform=Platform.NONE, em
4747
:param log_trace: If not None pass `--log <level>` to command.
4848
:param just_launch: If true pass `--justlaunch` to command.
4949
:param sync_all_files: If true pass `--syncAllFiles` to command.
50+
:param aab: If true pass `--aab` to command.
51+
:param compile_snapshot: If true pass `--env.compileSnapshot` to command.
5052
:param clean: If true pass `--clean` to command.
5153
:param options: Pass additional options as string.
5254
:param wait: If true it will wait until command is complete.
@@ -166,6 +168,8 @@ def create(app_name=Settings.AppName.DEFAULT, template=None, path=None, app_id=N
166168

167169
# Verify app is created properly
168170
if verify:
171+
# Verify exit code
172+
assert result.exit_code == 0, "Exit code of tns create is not 0."
169173
# Usually we do not pass path on tns create, which actually equals to cwd.
170174
# In such cases pass correct path to TnsAssert.created()
171175
if path is None:
@@ -451,6 +455,7 @@ def preview(app_name, bundle=True, hmr=True, log_trace=False, verify=True, timeo
451455
:param log_trace: If true pass --log trace.
452456
:param verify: If true verify some logs.
453457
:param timeout: Timeout in seconds.
458+
:param options: Pass additional options.
454459
:return: Result of `tns preview` command.
455460
"""
456461
result = Tns.exec_command(command='preview', path=app_name, bundle=bundle, hmr=hmr, wait=False,
@@ -490,6 +495,7 @@ def test(app_name, platform, emulator=True, device=None, just_launch=True, verif
490495
:param device: Pass `--device <value>` to command.
491496
:param just_launch: If true pass `--just_launch` to the command.
492497
:param verify: Verify command was executed successfully.
498+
:param wait: Wait command to complete it `true`.
493499
:return: Result of `tns test` command.
494500
"""
495501
cmd = 'test {0}'.format(str(platform))

products/nativescript/tns_assert.py

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def created(app_name, output=None, app_data=None, path=Settings.TEST_RUN_HOME, w
3535

3636
# Assert output
3737
if output is not None:
38+
assert 'Error:' not in output
3839
assert 'Now you can navigate to your project with $ cd' in output
3940
assert 'After that you can preview it on device by executing $ tns preview' in output
4041
assert 'After that you can run it on device/emulator by executing $ tns run <platform>' not in output

tests/cli/create/create_tests.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from products.nativescript.app import App
1111
from products.nativescript.tns import Tns
1212
from products.nativescript.tns_assert import TnsAssert
13+
from products.nativescript.tns_paths import TnsPaths
1314

1415

1516
# noinspection PyMethodMayBeStatic
@@ -123,10 +124,11 @@ def test_201_create_project_with_local_directory_template(self):
123124
"""--template should install all packages from package.json"""
124125
template_path = os.path.join(Settings.TEST_RUN_HOME, 'assets', 'myCustomTemplate')
125126
Tns.create(app_name=Settings.AppName.DEFAULT, template=template_path, update=False)
126-
assert not Folder.is_empty(os.path.join(Settings.AppName.DEFAULT, 'node_modules', 'lodash'))
127-
assert not Folder.is_empty(os.path.join(Settings.AppName.DEFAULT, 'node_modules', 'minimist'))
128-
assert not Folder.is_empty(os.path.join(Settings.AppName.DEFAULT, 'node_modules', 'tns-core-modules'))
129-
assert not Folder.is_empty(os.path.join(Settings.AppName.DEFAULT, 'node_modules', 'tns-core-modules-widgets'))
127+
node_modules = TnsPaths.get_app_node_modules_path(app_name=Settings.AppName.DEFAULT)
128+
assert not Folder.is_empty(os.path.join(node_modules, 'lodash'))
129+
assert not Folder.is_empty(os.path.join(node_modules, 'minimist'))
130+
assert not Folder.is_empty(os.path.join(node_modules, 'tns-core-modules'))
131+
assert not Folder.is_empty(os.path.join(node_modules, 'tns-core-modules-widgets'))
130132

131133
def test_400_create_project_with_wrong_template_path(self):
132134
"""--template should not create project if value is no npm installable"""

0 commit comments

Comments
 (0)