diff --git a/products/nativescript/tns.py b/products/nativescript/tns.py index d370571e..65e552a7 100644 --- a/products/nativescript/tns.py +++ b/products/nativescript/tns.py @@ -10,10 +10,10 @@ from core.log.log import Log from core.settings import Settings from core.utils.file_utils import Folder, File +from core.utils.json_utils import JsonUtils from core.utils.npm import Npm from core.utils.process import Process from core.utils.run import run -from core.utils.json_utils import JsonUtils from products.nativescript.app import App from products.nativescript.tns_assert import TnsAssert from products.nativescript.tns_logs import TnsLogs @@ -47,6 +47,8 @@ def exec_command(command, cwd=Settings.TEST_RUN_HOME, platform=Platform.NONE, em :param log_trace: If not None pass `--log ` to command. :param just_launch: If true pass `--justlaunch` to command. :param sync_all_files: If true pass `--syncAllFiles` to command. + :param aab: If true pass `--aab` to command. + :param compile_snapshot: If true pass `--env.compileSnapshot` to command. :param clean: If true pass `--clean` to command. :param options: Pass additional options as string. :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 # Verify app is created properly if verify: + # Verify exit code + assert result.exit_code == 0, "Exit code of tns create is not 0." # Usually we do not pass path on tns create, which actually equals to cwd. # In such cases pass correct path to TnsAssert.created() if path is None: @@ -451,6 +455,7 @@ def preview(app_name, bundle=True, hmr=True, log_trace=False, verify=True, timeo :param log_trace: If true pass --log trace. :param verify: If true verify some logs. :param timeout: Timeout in seconds. + :param options: Pass additional options. :return: Result of `tns preview` command. """ 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 :param device: Pass `--device ` to command. :param just_launch: If true pass `--just_launch` to the command. :param verify: Verify command was executed successfully. + :param wait: Wait command to complete it `true`. :return: Result of `tns test` command. """ cmd = 'test {0}'.format(str(platform)) diff --git a/products/nativescript/tns_assert.py b/products/nativescript/tns_assert.py index f013ee5f..cbd2bd75 100644 --- a/products/nativescript/tns_assert.py +++ b/products/nativescript/tns_assert.py @@ -35,6 +35,7 @@ def created(app_name, output=None, app_data=None, path=Settings.TEST_RUN_HOME, w # Assert output if output is not None: + assert 'Error:' not in output assert 'Now you can navigate to your project with $ cd' in output assert 'After that you can preview it on device by executing $ tns preview' in output assert 'After that you can run it on device/emulator by executing $ tns run ' not in output diff --git a/tests/cli/create/create_tests.py b/tests/cli/create/create_tests.py index d2f5e9fd..d06cf149 100644 --- a/tests/cli/create/create_tests.py +++ b/tests/cli/create/create_tests.py @@ -10,6 +10,7 @@ from products.nativescript.app import App from products.nativescript.tns import Tns from products.nativescript.tns_assert import TnsAssert +from products.nativescript.tns_paths import TnsPaths # noinspection PyMethodMayBeStatic @@ -123,10 +124,11 @@ def test_201_create_project_with_local_directory_template(self): """--template should install all packages from package.json""" template_path = os.path.join(Settings.TEST_RUN_HOME, 'assets', 'myCustomTemplate') Tns.create(app_name=Settings.AppName.DEFAULT, template=template_path, update=False) - assert not Folder.is_empty(os.path.join(Settings.AppName.DEFAULT, 'node_modules', 'lodash')) - assert not Folder.is_empty(os.path.join(Settings.AppName.DEFAULT, 'node_modules', 'minimist')) - assert not Folder.is_empty(os.path.join(Settings.AppName.DEFAULT, 'node_modules', 'tns-core-modules')) - assert not Folder.is_empty(os.path.join(Settings.AppName.DEFAULT, 'node_modules', 'tns-core-modules-widgets')) + node_modules = TnsPaths.get_app_node_modules_path(app_name=Settings.AppName.DEFAULT) + assert not Folder.is_empty(os.path.join(node_modules, 'lodash')) + assert not Folder.is_empty(os.path.join(node_modules, 'minimist')) + assert not Folder.is_empty(os.path.join(node_modules, 'tns-core-modules')) + assert not Folder.is_empty(os.path.join(node_modules, 'tns-core-modules-widgets')) def test_400_create_project_with_wrong_template_path(self): """--template should not create project if value is no npm installable"""