Skip to content

Commit 4e7adde

Browse files
author
Stefan Dragnev
committed
fix test run after initial installation
1 parent af1962a commit 4e7adde

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

lib/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export let NODE_MODULE_CACHE_PATH_KEY_NAME = "node-modules-cache-path";
1313
export let DEFAULT_APP_IDENTIFIER_PREFIX = "org.nativescript";
1414
export var LIVESYNC_EXCLUDED_DIRECTORIES = ["app_resources"];
1515
export var TESTING_FRAMEWORKS = ['jasmine', 'mocha'];
16+
export let TEST_RUNNER_NAME = "nativescript-unit-test-runner";
1617

1718
export class ReleaseType {
1819
static MAJOR = "major";

lib/services/platform-service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import * as semver from "semver";
99

1010
export class PlatformService implements IPlatformService {
1111
private static TNS_MODULES_FOLDER_NAME = "tns_modules";
12-
private static TNS_UNIT_TEST_RUNNER = "nativescript-unit-test-runner";
1312

1413
constructor(private $devicesServices: Mobile.IDevicesServices,
1514
private $errors: IErrors,
@@ -196,8 +195,8 @@ export class PlatformService implements IPlatformService {
196195
let tnsModulesDestinationPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME, PlatformService.TNS_MODULES_FOLDER_NAME);
197196
this.$broccoliBuilder.prepareNodeModules(tnsModulesDestinationPath, platform, lastModifiedTime).wait();
198197

199-
let testRunnerSourcePath = path.join(this.$projectData.projectDir, 'node_modules', PlatformService.TNS_UNIT_TEST_RUNNER);
200-
shell.rm("-rf", path.join(tnsModulesDestinationPath, PlatformService.TNS_UNIT_TEST_RUNNER));
198+
let testRunnerSourcePath = path.join(this.$projectData.projectDir, 'node_modules', constants.TEST_RUNNER_NAME);
199+
shell.rm("-rf", path.join(tnsModulesDestinationPath, constants.TEST_RUNNER_NAME));
201200
if (!this.$options.release && this.$fs.exists(testRunnerSourcePath).wait()) {
202201
shell.cp("-Rf", testRunnerSourcePath, tnsModulesDestinationPath);
203202
}

lib/services/test-execution-service.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import Future = require('fibers/future');
88
import * as os from 'os';
99

1010
class TestExecutionService implements ITestExecutionService {
11-
private static RUNNER_BASE_PATH = './tns_modules/nativescript-unit-test-runner/';
12-
private static MAIN_APP_NAME = TestExecutionService.RUNNER_BASE_PATH + 'app.js';
13-
private static CONFIG_FILE_NAME = TestExecutionService.RUNNER_BASE_PATH + 'config.js';
14-
private static SOCKETIO_JS_FILE_NAME = TestExecutionService.RUNNER_BASE_PATH + 'socket.io.js';
11+
private static MAIN_APP_NAME = `./tns_modules/${constants.TEST_RUNNER_NAME}/app.js`;
12+
private static CONFIG_FILE_NAME = `node_modules/${constants.TEST_RUNNER_NAME}/config.js`;
13+
private static SOCKETIO_JS_FILE_NAME = `node_modules/${constants.TEST_RUNNER_NAME}/socket.io.js`;
1514

1615
constructor(
1716
private $projectData: IProjectData,
@@ -29,21 +28,24 @@ class TestExecutionService implements ITestExecutionService {
2928

3029
public startTestRunner(platform: string) : IFuture<void> {
3130
return (() => {
31+
this.$options.justlaunch = true;
32+
3233
let platformData = this.$platformsData.getPlatformData(platform);
34+
let projectDir = this.$projectData.projectDir;
3335

3436
let projectFilesPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
3537

36-
this.$platformService.preparePlatform(platform).wait();
37-
this.detourEntryPoint(projectFilesPath).wait();
38-
3938
let configJs = this.generateConfig(this.$options.port);
40-
this.$fs.writeFile(path.join(projectFilesPath, TestExecutionService.CONFIG_FILE_NAME), configJs).wait();
39+
this.$fs.writeFile(path.join(projectDir, TestExecutionService.CONFIG_FILE_NAME), configJs).wait();
4140

4241
let socketIoJsUrl = `http://localhost:${this.$options.port}/socket.io/socket.io.js`;
4342
let socketIoJs = this.$httpClient.httpRequest(socketIoJsUrl).wait().body;
44-
this.$fs.writeFile(path.join(projectFilesPath, TestExecutionService.SOCKETIO_JS_FILE_NAME), socketIoJs).wait();
43+
this.$fs.writeFile(path.join(projectDir, TestExecutionService.SOCKETIO_JS_FILE_NAME), socketIoJs).wait();
44+
45+
this.$platformService.preparePlatform(platform).wait();
46+
this.detourEntryPoint(projectFilesPath).wait();
4547

46-
let watchGlob = path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME);
48+
let watchGlob = path.join(projectDir, constants.APP_FOLDER_NAME);
4749

4850
let platformSpecificLiveSyncServices: IDictionary<any> = {
4951
android: (_device: Mobile.IDevice, $injector: IInjector): IPlatformSpecificLiveSyncService => {

0 commit comments

Comments
 (0)