11
11
from core .enums .platform_type import Platform
12
12
from core .settings import Settings
13
13
from core .utils .device .simctl import Simctl
14
- from core .utils .file_utils import Folder
14
+ from core .utils .file_utils import Folder , File
15
15
from core .utils .npm import Npm
16
16
from data .templates import Template
17
17
from products .nativescript .run_type import RunType
24
24
class TestRunWithScopedPackages (TnsRunTest ):
25
25
test_data = [
26
26
[Template .HELLO_WORLD_JS .name .replace ('template-' , '' ), Template .HELLO_WORLD_JS ],
27
- # Skip TS projects because on TS projects we need to update all requires in the app in order to make it work.
28
- # [Template.HELLO_WORLD_TS.name.replace('template-', ''), Template.HELLO_WORLD_TS],
27
+ [Template .HELLO_WORLD_TS .name .replace ('template-' , '' ), Template .HELLO_WORLD_TS ],
29
28
[Template .HELLO_WORLD_NG .name .replace ('template-' , '' ), Template .HELLO_WORLD_NG ],
30
- # Skip MasterDetailNG, it fails, need to be investigated.
31
- # [Template.MASTER_DETAIL_NG.name.replace('template-', ''), Template.MASTER_DETAIL_NG],
29
+ [Template .MASTER_DETAIL_NG .name .replace ('template-' , '' ), Template .MASTER_DETAIL_NG ],
32
30
]
33
31
34
32
@parameterized .expand (test_data )
@@ -40,6 +38,17 @@ def test_scoped_package_only(self, app_name, template_info):
40
38
Tns .create (app_name = app_name , template = template_info .local_package , update = True )
41
39
Npm .uninstall (package = 'tns-core-modules' , option = '--save' , folder = app_path )
42
40
Npm .install (package = Settings .Packages .NATIVESCRIPT_CORE , option = '--save --save-exact' , folder = app_path )
41
+
42
+ # Replace imports
43
+ if template_info == Template .HELLO_WORLD_TS :
44
+ files = File .find_by_extension (folder = os .path .join (app_path , 'app' ), extension = 'ts' )
45
+ for file in files :
46
+ File .replace (path = file , old_string = 'tns-core-modules' , new_string = '@nativescript/core' , fail_safe = True )
47
+ if template_info == Template .MASTER_DETAIL_NG :
48
+ files = File .find_by_extension (folder = os .path .join (app_path , 'src' ), extension = 'ts' )
49
+ for file in files :
50
+ File .replace (path = file , old_string = 'tns-core-modules' , new_string = '@nativescript/core' , fail_safe = True )
51
+
43
52
Tns .platform_add_android (app_name = app_name , framework_path = Settings .Android .FRAMEWORK_PATH )
44
53
if Settings .HOST_OS is OSType .OSX :
45
54
Tns .platform_add_ios (app_name = app_name , framework_path = Settings .IOS .FRAMEWORK_PATH )
0 commit comments