def setUpClass(cls):
     TnsTest.setUpClass()
     cls.emulator = DeviceManager.Emulator.ensure_available(
         Emulators.DEFAULT)
     Folder.clean(os.path.join(TEST_RUN_HOME, APP_NAME))
     Tns.create(app_name=APP_NAME,
                template=Template.HELLO_WORLD_JS.local_package,
                update=True)
     Tns.platform_add_android(APP_NAME,
                              framework_path=Android.FRAMEWORK_PATH)
     Adb.run_adb_as_root(cls.emulator.id)
 def setUpClass(cls):
     TnsTest.setUpClass()
     Tns.create(app_name=APP_NAME,
                template=Template.HELLO_WORLD_JS.local_package,
                update=True)
     Tns.platform_add_android(
         app_name=APP_NAME, framework_path=Settings.Android.FRAMEWORK_PATH)
     Tns.platform_add_ios(app_name=APP_NAME,
                          framework_path=Settings.IOS.FRAMEWORK_PATH)
     Tns.prepare_android(app_name=APP_NAME)
     Tns.prepare_ios(app_name=APP_NAME)
Example #3
0
 def test_402_create_project_in_folder_with_existing_project(self):
     """Create project with name that already exist should show friendly error message"""
     # webpack - remove template after merge
     Tns.create(app_name=Settings.AppName.DEFAULT,
                template=Template.HELLO_WORLD_JS.local_package,
                update=False)
     result = Tns.create(app_name=Settings.AppName.DEFAULT,
                         update=False,
                         verify=False,
                         force_clean=False)
     assert "successfully created" not in result.output
     assert "Path already exists and is not empty" in result.output
Example #4
0
 def test_200_build_android_release(self):
     if Settings.HOST_OS != OSType.WINDOWS:
         Tns.build_android(app_name=self.ng_app,
                           release=True,
                           bundle=True,
                           aot=True,
                           uglify=True,
                           snapshot=True)
     else:
         Tns.build_android(app_name=self.ng_app,
                           release=True,
                           snapshot=True)
Example #5
0
 def test_400_invalid_framework_name(self):
     result = Tns.create(app_name=APP_NAME,
                         template=Template.HELLO_WORLD_JS.local_package,
                         update=False,
                         verify=False)
     TnsAssert.created(app_name=APP_NAME,
                       output=result.output,
                       theme=False,
                       webpack=False)
     result = Tns.test_init(app_name=APP_NAME,
                            framework='jasmin',
                            verify=False)
     assert 'Unknown or unsupported unit testing framework: jasmin' in result.output
    def __console_eval(self, platform, device):
        # Run `tns debug` wait until debug url is in the console and app is loaded
        Tns.debug(app_name=self.app_name, platform=platform, emulator=True)
        device.wait_for_text(text='TAP')

        # Open Chrome Dev Tools -> Console
        self.dev_tools = ChromeDevTools(self.chrome,
                                        platform=platform,
                                        tab=ChromeDevToolsTabs.CONSOLE)

        # Evaluate on console
        self.dev_tools.type_on_console("1024+1024")
        self.dev_tools.wait_element_by_text(text='2048', timeout=10)
    def setUpClass(cls):
        TnsRunTest.setUpClass()

        # Create app
        Tns.create(app_name=cls.app_name, template=Template.HELLO_WORLD_JS.local_package, update=True)
        Tns.platform_add_android(app_name=cls.app_name, framework_path=Android.FRAMEWORK_PATH)

        # Copy TestApp to data folder.
        Folder.copy(source=cls.app_path, target=cls.target_project_dir)

        # Download bundletool
        url = 'https://github.com/google/bundletool/releases/download/0.10.0/bundletool-all-0.10.0.jar'
        File.download('bundletool.jar', url, TEST_SUT_HOME)
    def test_322_extends_method_is_working_in_non_native_inheritance(self):
        """
        Test __extends is working non native inheritance
        https://github.com/NativeScript/android-runtime/issues/1181
        """
        Folder.clean(os.path.join(TEST_RUN_HOME, APP_NAME))
        Tns.create(APP_NAME,
                   template=Template.VUE_BLANK.local_package,
                   verify=False)
        Tns.platform_add_android(APP_NAME,
                                 framework_path=Android.FRAMEWORK_PATH)

        source_js = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android',
                                 'files', 'android-runtime-1181', 'js',
                                 'app.js')
        target_js = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'app.js')
        File.copy(source=source_js, target=target_js, backup_files=True)

        log = Tns.run_android(APP_NAME,
                              device=self.emulator.id,
                              wait=False,
                              verify=False,
                              bundle=True)

        strings = [
            'Successfully synced application',
            "'NativeScript-Vue has \"Vue.config.silent\" set to true, to see output logs set it to false.'"
        ]

        test_result = Wait.until(lambda: all(string in File.read(log.log_file)
                                             for string in strings),
                                 timeout=300,
                                 period=5)
        message = 'Test __extends is working non native inheritance ts code fails! Logs:'
        assert test_result, message + File.read(log.log_file)

        source_js = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android',
                                 'files', 'android-runtime-1181', 'ts',
                                 'app.js')
        target_js = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'app.js')
        File.copy(source=source_js, target=target_js, backup_files=True)

        test_result = Wait.until(
            lambda:
            "'NativeScript-Vue has \"Vue.config.silent\" set to true, to see output logs set it to false.'"
            in File.read(log.log_file),
            timeout=300,
            period=5)

        assert test_result, 'Test extends is working non native inheritance fails for js code!'
        def test_210_plugin_add_static_lib_universal(self):
            plugin_path = os.path.join(Settings.TEST_RUN_HOME, 'assets',
                                       'plugins', 'hello-plugin.tgz')
            result = Tns.plugin_add(plugin_path,
                                    path=Settings.AppName.DEFAULT,
                                    verify=False)
            assert "Successfully installed plugin hello." in result.output

            assert File.exists(
                os.path.join(TnsPaths.get_app_node_modules_path(self.app_name),
                             'hello', 'package.json'))
            assert File.exists(
                os.path.join(TnsPaths.get_app_node_modules_path(self.app_name),
                             'hello', 'hello-plugin.ios.js'))
            assert File.exists(
                os.path.join(TnsPaths.get_app_node_modules_path(self.app_name),
                             'hello', 'platforms', 'ios', 'HelloLib.a'))
            assert File.exists(
                os.path.join(TnsPaths.get_app_node_modules_path(self.app_name),
                             'hello', 'platforms', 'ios', 'include',
                             'HelloLib', 'Bye.h'))
            assert File.exists(
                os.path.join(TnsPaths.get_app_node_modules_path(self.app_name),
                             'hello', 'platforms', 'ios', 'include',
                             'HelloLib', 'Hello.h'))
            output = File.read(os.path.join(self.app_name, 'package.json'))
            assert "plugins/hello-plugin" in output

            # Require the plugin so webpack can pick it up
            main_js_file = os.path.join(Settings.TEST_RUN_HOME, self.app_name,
                                        'app', 'main-page.js')
            File.append(main_js_file, 'const hello = require("hello");')

            Tns.prepare_ios(self.app_name)

            bundle_js = File.read(
                os.path.join(
                    TnsPaths.get_platforms_ios_app_path(self.app_name),
                    'bundle.js'))
            vendor_js = File.read(
                os.path.join(
                    TnsPaths.get_platforms_ios_app_path(self.app_name),
                    'vendor.js'))
            assert '__webpack_require__("../node_modules/hello/hello-plugin.js")' in bundle_js
            assert 'hello = Hello.alloc().init();' in vendor_js

            result = run("cat " + os.path.join(
                TnsPaths.get_platforms_ios_folder(self.app_name),
                'TestApp.xcodeproj', 'project.pbxproj | grep \"HelloLib.a\"'))
            assert "HelloLib.a in Frameworks" in result.output
Example #10
0
    def __create_and_build_app(self):
        Tns.create(app_name=self.app_name,
                   template=Template.HELLO_WORLD_JS.local_package,
                   update=False)
        Tns.platform_add_android(
            app_name=self.app_name,
            framework_path=Settings.Android.FRAMEWORK_PATH)
        if Settings.HOST_OS == OSType.OSX:
            Tns.platform_add_ios(app_name=self.app_name,
                                 framework_path=Settings.IOS.FRAMEWORK_PATH)

        Tns.build_android(self.app_name)
        if Settings.HOST_OS == OSType.OSX:
            Tns.build_ios(self.app_name)
Example #11
0
 def test_010_create_app_remove_app_resources(self):
     # creates valid project from local directory template
     tns_ts_template_path = os.path.join(Settings.TEST_SUT_HOME,
                                         'templates', 'packages',
                                         'template-hello-world-ts')
     Folder.clean(os.path.join(Settings.AppName.DEFAULT))
     Folder.clean(os.path.join(tns_ts_template_path, 'app',
                               'App_Resources'))
     file_path = os.path.join(tns_ts_template_path, 'package.json')
     File.replace(path=file_path,
                  old_string="tns-template-hello-world-ts",
                  new_string="test-tns-template-hello-world-ts")
     Tns.create(app_name=Settings.AppName.DEFAULT,
                template=tns_ts_template_path)
Example #12
0
 def test_200_plugin_platforms_should_not_exist_in_tns_modules_android(
         self):
     """
     Test for issue https://github.com/NativeScript/nativescript-cli/issues/3932
     """
     issue_path = os.path.join(Settings.TEST_RUN_HOME, 'assets', 'issues',
                               'nativescript-cli-3932')
     Tns.platform_remove(app_name=self.app_name, platform=Platform.ANDROID)
     Tns.plugin_add(plugin_name='nativescript-ui-listview',
                    path=self.app_name)
     Folder.clean(os.path.join(self.app_name, 'node_modules'))
     File.delete(os.path.join(self.app_name, 'package.json'))
     copy = os.path.join(issue_path, 'nativescript-ui-listview')
     paste = os.path.join(self.app_path, 'nativescript-ui-listview')
     Folder.copy(copy, paste)
     copy = os.path.join(issue_path, 'package.json')
     paste = os.path.join(self.app_name)
     File.copy(copy, paste)
     Tns.platform_add_android(
         app_name=self.app_name,
         framework_path=Settings.Android.FRAMEWORK_PATH)
     folder_path = os.path.join(self.app_path, 'nativescript-ui-listview')
     Npm.install(option='--ignore-scripts', folder=folder_path)
     Tns.build_android(app_name=self.app_name, bundle=False)
     app_path = os.path.join(
         TnsPaths.get_platforms_android_npm_modules(self.app_name))
     assert not File.exists(
         os.path.join(app_path, 'nativescript-ui-listview', 'node_modules',
                      'nativescript-ui-core', 'platforms'))
Example #13
0
 def setUpClass(cls):
     TnsTest.setUpClass()
     Tns.create(app_name=cls.app_name, template=Template.HELLO_WORLD_JS.local_package, update=True)
     Tns.create(cls.app_name_with_space, template=Template.HELLO_WORLD_JS.local_package, update=True)
     # Folder.clean(os.path.join(cls.app_name, 'hooks'))
     # Folder.clean(os.path.join(cls.app_name, 'node_modules'))
     # Folder.clean(os.path.join(cls.app_name_with_space, 'hooks'))
     # Folder.clean(os.path.join(cls.app_name_with_space, 'node_modules'))
     Tns.platform_add_android(cls.app_name, framework_path=Settings.Android.FRAMEWORK_PATH)
     Tns.platform_add_android(app_name='"' + cls.app_name_with_space + '"',
                              framework_path=Settings.Android.FRAMEWORK_PATH, verify=False)
     if Settings.HOST_OS is OSType.OSX:
         Tns.platform_add_ios(cls.app_name, framework_path=Settings.IOS.FRAMEWORK_PATH)
     Folder.copy(cls.app_path, cls.app_temp_path)
    def test_200_prepare_additional_appresources(self):
        Tns.prepare_ios(self.app_name)

        # Create new files in AppResources
        File.copy(os.path.join(TnsPaths.get_path_app_resources(self.app_name), 'iOS', 'Assets.xcassets',
                               'AppIcon.appiconset', 'icon-76.png'),
                  os.path.join(TnsPaths.get_path_app_resources(self.app_name), 'iOS', 'newDefault.png'))

        Tns.prepare_ios(self.app_name)

        # Verify XCode Project include files from App Resources folder
        result = run("cat " + os.path.join(TnsPaths.get_platforms_ios_folder(self.app_name), 'TestApp.xcodeproj',
                                           'project.pbxproj | grep newDefault.png'))
        assert "newDefault.png" in result.output
 def setUpClass(cls):
     TnsTest.setUpClass()
     Folder.clean(os.path.join(TEST_RUN_HOME, APP_NAME))
     Tns.create(app_name=APP_NAME, template=Template.HELLO_WORLD_NG.local_package)
     json = App.get_package_json(app_name=APP_NAME)
     cls.app_id = json['nativescript']['id']
     devices = Adb.get_ids(include_emulators=False)
     device_id = None
     for device in devices:
         device_id = device
     if device_id is not None:
         cls.device = Device(id=device_id, name=device_id, type=DeviceType.ANDROID,
                             version=Adb.get_version(device_id))
     Adb.uninstall(cls.app_id, device_id, assert_success=False)
Example #16
0
 def setUpClass(cls):
     TnsRunTest.setUpClass()
     app_folder = os.path.join(Settings.TEST_RUN_HOME, cls.app_name)
     Folder.clean(app_folder)
     Git.clone(
         repo_url='https://github.com/NativeScript/chrome-devtools-test-app',
         local_folder=app_folder)
     Tns.platform_add_android(
         app_name=cls.app_name,
         framework_path=Settings.Android.FRAMEWORK_PATH)
     if Settings.HOST_OS == OSType.OSX:
         Tns.platform_add_ios(app_name=cls.app_name,
                              framework_path=Settings.IOS.FRAMEWORK_PATH)
     App.update(app_name=cls.app_name)
    def test_451_support_external_buildscript_config_in_plugin(self):
        """
        Support external buildscript configurations - buildscript.gradle file placed in plugin folder
        https://github.com/NativeScript/android-runtime/issues/1279
        """
        Tns.plugin_remove("sample-plugin", verify=False, path=APP_NAME)

        source_app_gradle = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files', 'android-runtime-1279',
                                         'in-plugin', 'app.gradle')
        target_app_gradle = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources', 'Android', 'app.gradle')
        File.copy(source=source_app_gradle, target=target_app_gradle, backup_files=True)

        source_build_script_gradle = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files',
                                                  'android-runtime-1279', 'buildscript.gradle')
        target_build_script_gradle = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources', 'Android')
        File.copy(source=source_build_script_gradle, target=target_build_script_gradle, backup_files=True)

        plugin_path = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files', 'android-runtime-1279',
                                   'in-plugin',
                                   'sample-plugin-2', 'src')
        Tns.plugin_add(plugin_path, path=APP_NAME, verify=False)

        Tns.build_android(os.path.join(TEST_RUN_HOME, APP_NAME), verify=True)

        Tns.plugin_remove("sample-plugin-2", verify=False, path=APP_NAME)
Example #18
0
    def test_007_create_project_named_123(self):
        """Create app starting with digits should not be possible without --force option"""
        result = Tns.create(app_name=Settings.AppName.WITH_NUMBER,
                            template=Template.HELLO_WORLD_JS.local_package,
                            app_data=Apps.HELLO_WORLD_JS,
                            update=False,
                            verify=False)
        assert 'The project name does not start with letter and will fail to build for Android.' in result.output
        assert 'If You want to create project with this name add --force to the create command.' in result.output

        Tns.create(app_name=Settings.AppName.WITH_NUMBER,
                   template=Template.HELLO_WORLD_JS.local_package,
                   app_data=Apps.HELLO_WORLD_JS,
                   force=True,
                   update=False)
Example #19
0
 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)
     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_301_build_project_with_space_release(self):

        # Ensure ANDROID_KEYSTORE_PATH contain spaces (verification for CLI issue 2650)
        Folder.create("with space")
        file_name = os.path.basename(Settings.Android.ANDROID_KEYSTORE_PATH)
        cert_with_space_path = os.path.join("with space", file_name)
        File.copy(Settings.Android.ANDROID_KEYSTORE_PATH, cert_with_space_path)

        Tns.build_android(app_name='"' + self.app_name_with_space + '"', release=True)
        output = File.read(os.path.join(self.app_name_with_space, "package.json"))
        assert self.app_identifier in output.lower()

        output = File.read(os.path.join(TnsPaths.get_platforms_android_src_main_path(self.app_name_with_space),
                                        'AndroidManifest.xml'))
        assert self.app_identifier in output.lower()
    def test_300_tns_resources_update(self):
        # Create nativescript@3 app
        result = Tns.create(app_name=APP_NAME,
                            template='[email protected]',
                            verify=False,
                            update=False)
        TnsAssert.created(app_name=APP_NAME,
                          output=result.output,
                          webpack=False)

        # Update resources
        out = Tns.exec_command(command='resources update',
                               path=APP_NAME).output
        assert "Successfully updated your project's application resources '/Android' directory structure." in out
        assert "The previous version of your Android application resources has been renamed to '/Android-Pre-v4'" in out
Example #22
0
    def test_500_test_ES6_support(self):
        """
         https://github.com/NativeScript/android-runtime/issues/1375
        """
        Folder.clean(os.path.join(TEST_RUN_HOME, APP_NAME))
        Tns.create(
            app_name=APP_NAME,
            template="https://github.com/NativeScript/es6-syntax-app.git",
            update=True)

        Tns.platform_add_android(APP_NAME,
                                 framework_path=Android.FRAMEWORK_PATH)
        log = Tns.run_android(APP_NAME,
                              device=self.emulator.id,
                              wait=False,
                              verify=False)
        strings = [
            'Successfully synced application', 'on device', self.emulator.id
        ]

        test_result = Wait.until(lambda: all(string in File.read(log.log_file)
                                             for string in strings),
                                 timeout=120,
                                 period=5)
        assert test_result, "App not build correctly after updating tns-core modules! Logs: " + File.read(
            log.log_file)
        button_text = "Use ES6 language features"

        test_result = Wait.until(
            lambda: Device.is_text_visible(self.emulator, button_text),
            timeout=30,
            period=5)
        message = "Use ES6 language features Button is missing on the device! The app has crashed!"
        assert test_result, message

        Device.click(self.emulator, text=button_text, case_sensitive=False)
        test_result = Wait.until(
            lambda: "class com.js.NativeList" in File.read(log.log_file),
            timeout=25,
            period=5)
        assert test_result, "com.js.NativeList not found! Logs: " + File.read(
            log.log_file)

        test_result = Wait.until(
            lambda: Device.is_text_visible(self.emulator, button_text),
            timeout=30,
            period=5)
        assert test_result, message
Example #23
0
 def test_10_run(self, name, platform, aot, uglify):
     if (platform
             == Platform.IOS) and (Settings.HOST_OS == OSType.WINDOWS
                                   or Settings.HOST_OS == OSType.LINUX):
         unittest.skip('Can not run iOS tests on Windows or Linux.')
     else:
         ng_app_text = 'auto-generated works!'
         Tns.run(platform=platform,
                 app_name=self.app_name,
                 aot=aot,
                 uglify=uglify,
                 emulator=True)
         if platform == Platform.ANDROID:
             self.emu.wait_for_text(text=ng_app_text, timeout=300)
         if platform == Platform.IOS:
             self.sim.wait_for_text(text=ng_app_text, timeout=300)
Example #24
0
    def test_250_check_plugin_dependencies_are_found(self):
        """
         Test that all plugin's dependencies are found
         https://github.com/NativeScript/android-runtime/issues/1379
        """
        Tns.plugin_add(plugin_name="nativescript-image",
                       path=os.path.join(TEST_RUN_HOME, APP_NAME))
        log = Tns.build_android(os.path.join(TEST_RUN_HOME, APP_NAME))

        strings = ['WARNING: Skipping interface', 'as it cannot be resolved']
        test_result = Wait.until(lambda: all(string not in log.output
                                             for string in strings),
                                 timeout=10,
                                 period=5)

        assert test_result, 'It seems that not all plugin\'s dependencies are found!'
Example #25
0
    def test_300_verbose_log_android(self):
        File.copy(
            os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android',
                         'files', 'verbose_log', 'app.js'),
            os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'app.js'), True)
        output = File.read(
            os.path.join(TEST_RUN_HOME, APP_NAME, "app", "app.js"))
        assert "__enableVerboseLogging()" in output, "Verbose logging not enabled in app.js"

        # `tns run android` and wait until app is deployed
        log = Tns.run_android(APP_NAME,
                              device=self.emulator.id,
                              wait=False,
                              verify=False)

        strings = [
            'Project successfully built',
            'Successfully installed on device with identifier', 'TNS.Native',
            'TNS.Java', self.emulator.id
        ]

        Wait.until(lambda: all(string in File.read(log.log_file)
                               for string in strings),
                   timeout=240,
                   period=5)
        log = File.read(log.log_file)
        assert "TNS.Native" in log, "__enableVerboseLogging() do not enable TNS.Native logs!"
        assert "TNS.Java" in log, "__enableVerboseLogging() do not enable TNS.Java logs!"
    def __console_log(self, platform, device):
        # Run `tns debug` wait until debug url is in the console and app is loaded
        result = Tns.debug(app_name=self.app_name,
                           platform=platform,
                           emulator=True)
        device.wait_for_text(text='TAP')

        # Open Chrome Dev Tools -> Console
        self.dev_tools = ChromeDevTools(self.chrome,
                                        platform=platform,
                                        tab=ChromeDevToolsTabs.CONSOLE)

        # TAP the button to trigger console log and ensure it is in device logs
        device.click(text='TAP', case_sensitive=True)
        assert device.wait_for_log(
            text='Test Debug!',
            timeout=90), 'Console logs not available in device logs.'

        # Ensure logs are available in tns logs
        tns_logs = File.read(result.log_file)
        assert "Test Debug!" in tns_logs, 'Console log messages not available in CLI output.' + os.linesep + tns_logs
        message = 'Console log messages(Arabic and Kurdish characters) not available in CLI output.'
        # add test for issue https://github.com/NativeScript/android-runtime/issues/1302
        assert 'العربییە' in tns_logs, message + os.linesep + tns_logs

        # Verify console logs are available in Chrome dev tools
        log = self.dev_tools.wait_element_by_text(text='Test Debug!')
        assert log is not None, 'Console logs not displayed in Chrome Dev Tools.'
        if Settings.PYTHON_VERSION < 3:
            text = 'العربییە'.decode('utf-8')
        else:
            text = 'العربییە'
        log = self.dev_tools.wait_element_by_text(text=text)
        # add test for issue https://github.com/NativeScript/android-runtime/issues/1302
        assert log is not None, 'Console logs(Arabic and Kurdish characters) not displayed in Chrome Dev Tools.'
    def __debug_sync_changes(self, platform, device):
        # Start debug and wait until app is deployed
        result = Tns.debug(app_name=self.app_name,
                           platform=platform,
                           emulator=True)
        device.wait_for_text(text='TAP')

        # Open sources tab and verify content is loaded
        self.dev_tools = ChromeDevTools(self.chrome,
                                        platform=platform,
                                        tab=ChromeDevToolsTabs.SOURCES)

        # Open JS file and place breakpoint on line 18
        self.dev_tools.load_source_file("main-view-model.js")
        self.dev_tools.breakpoint(18)

        # Sync JS changes works fine until breakpoint is hit
        Sync.replace(app_name=self.app_name, change_set=Changes.JSHelloWord.JS)
        js_file_name = os.path.basename(Changes.JSHelloWord.JS.file_path)
        logs = [
            js_file_name, 'Webpack build done!', 'Refreshing application',
            'Successfully synced application'
        ]
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=logs)
        device.wait_for_text(text=Changes.JSHelloWord.JS.new_text, timeout=30)

        # Revert changes
        Sync.revert(app_name=self.app_name, change_set=Changes.JSHelloWord.JS)
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=logs)
        device.wait_for_text(text=Changes.JSHelloWord.JS.old_text, timeout=30)

        # Tap on TAP button in emulator and check it is hit
        device.click(text="TAP", case_sensitive=True)
        pause_element = self.dev_tools.wait_element_by_text(
            text="Paused on breakpoint", timeout=90)
        assert pause_element is not None, 'Failed to pause on breakpoint.'

        # Test for https://github.com/NativeScript/nativescript-cli/issues/4227
        Sync.replace(app_name=self.app_name, change_set=self.xml_change)
        xml_file_name = os.path.basename(self.xml_change.file_path)
        logs = [
            xml_file_name, 'Webpack build done!', 'Refreshing application',
            'Successfully synced application'
        ]
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=logs)
        sleep(10)  # Give it some more time to crash
        logs = File.read(result.log_file)
        assert 'Unable to apply changes' not in logs
        assert 'Stopping webpack watch' not in logs
        assert 'closed' not in logs
        assert 'detached' not in logs
        assert "did not start in time" not in logs

        # Resume execution
        self.dev_tools.continue_debug()
        device.wait_for_text(
            text='42 taps left',
            timeout=30)  # We tapped but changes synced so number is restarted
        device.wait_for_text(text=self.xml_change.new_text,
                             timeout=10)  # Verify change applied during debug
    def test_001_build_ios(self):
        Tns.platform_remove(self.app_name, platform=Platform.ANDROID)
        Tns.build_ios(self.app_name)
        Tns.build_ios(self.app_name, release=True)
        Tns.build_ios(self.app_name, for_device=True)
        Tns.build_ios(self.app_name, for_device=True, release=True)
        assert not File.exists(os.path.join(TnsPaths.get_platforms_ios_folder(self.app_name), '*.aar'))
        assert not File.exists(os.path.join(TnsPaths.get_platforms_ios_npm_modules(self.app_name), '*.framework'))

        # Verify ipa has both armv7 and arm64 archs
        ipa_path = TnsPaths.get_ipa_path(app_name=self.app_name, release=True, for_device=True)
        run("mv " + ipa_path + " TestApp-ipa.tgz")
        run("unzip -o TestApp-ipa.tgz")
        result = run("lipo -info Payload/TestApp.app/TestApp")
        Folder.clean("Payload")
        assert "Architectures in the fat file: Payload/TestApp.app/TestApp are: armv7 arm64" in result.output
 def test_302_build_project_with_space_debug_with_plugin(self):
     # skip remove platform because androidx is not released official
     app_space_path = TnsPaths.get_app_path(app_name=self.app_name_with_space)
     # Tns.platform_remove(app_name='"' + self.app_name_with_space + '"', platform=Platform.ANDROID)
     Npm.install(package='nativescript-mapbox', option='--save', folder=app_space_path)
     result = Tns.build_android(app_name='"' + self.app_name_with_space + '"')
     assert "Project successfully built" in result.output
    def test_302_test_SBG_works_when_you_have_nativescript_property_in_package_json(self):
        """
         https://github.com/NativeScript/android-runtime/issues/1409
        """

        source_js = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files', 'android-runtime-1409',
                                 'package.json')
        target_js = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'package.json')
        File.copy(source=source_js, target=target_js, backup_files=True)
        source_js = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files', 'android-runtime-1409',
                                 'new', 'package.json')
        target_js = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'new', 'package.json')
        new_folder = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'new')
        Folder.create(new_folder)
        File.copy(source=source_js, target=target_js, backup_files=True)
        webpack_config = os.path.join(TEST_RUN_HOME, APP_NAME, 'webpack.config.js')
        old_string = 'new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"),'
        new_string = 'new CopyWebpackPlugin(dataToCopy), new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"),'
        File.replace(path=webpack_config, old_string=old_string, new_string=new_string, backup_files=True)
        old_string = 'const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));'
        new_string = """    const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
        const fileName = "package.json"
        const dataInfo =  {
            from: `../app/new/${fileName}`,
            to: `${dist}/new/${fileName}`,
        }
        env.externals = [fileName];
        const dataToCopy = [dataInfo];"""
        File.replace(path=webpack_config, old_string=old_string, new_string=new_string, backup_files=False)
        log = Tns.build_android(os.path.join(TEST_RUN_HOME, APP_NAME), verify=False).output
        test_result = Wait.until(lambda: "Project successfully built." in log, timeout=300, period=5)
        assert test_result, 'App not build correct! Logs:' + log