Skip to content

Commit 1ab5255

Browse files
author
Fatme
authored
Merge pull request #28 from NativeScript/fatme/feat-respect-nsconfig
feat: respect nsconfig file from project and correctly navigate to run tests page
2 parents 56e5dfd + 86be247 commit 1ab5255

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

app-root.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<Frame defaultPage="./tns_modules/nativescript-unit-test-runner/main-page">
1+
<Frame defaultPage="./tns_modules/nativescript-unit-test-runner/main-page" id="root-frame">
22
</Frame>

main-view-model.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface IHostConfiguration {
1414
options: {
1515
debugBrk?: boolean;
1616
debugTransport?: boolean;
17+
appDirectoryRelativePath?: string;
1718
}
1819
}
1920

@@ -42,7 +43,10 @@ function enableSocketIoDebugging() {
4243
}
4344

4445
var config: INetworkConfiguration = require('./config');
45-
config.options = config.options || {}
46+
config.options = config.options || {};
47+
if (!config.options.appDirectoryRelativePath) {
48+
config.options.appDirectoryRelativePath = "app";
49+
}
4650

4751
export class TestBrokerViewModel extends observable.Observable {
4852
private startEmitted: boolean;
@@ -189,13 +193,13 @@ export class TestBrokerViewModel extends observable.Observable {
189193
}
190194

191195
public viewTestRunDetails() {
192-
frameModule.topmost().navigate('run-details');
196+
frameModule.getFrameById('root-frame').navigate('run-details');
193197
}
194198

195199
public beginLocalRun() {
196200
this.config = this.config || { args: [] };
197201

198-
frameModule.topmost().navigate('tns_modules/nativescript-unit-test-runner/test-run-page');
202+
frameModule.getFrameById('root-frame').navigate('tns_modules/nativescript-unit-test-runner/test-run-page');
199203
}
200204

201205
public onKarmaExecute(cfg) {
@@ -225,7 +229,7 @@ export class TestBrokerViewModel extends observable.Observable {
225229
})
226230
.then(scriptUrls => {
227231
return Promise.all(scriptUrls.map((url): Promise<IScriptInfo> => {
228-
var appPrefix = '/base/app/';
232+
var appPrefix = `/base/${config.options.appDirectoryRelativePath}/`;
229233
if (url.startsWith(appPrefix)) {
230234
var paramsStart = url.indexOf('?');
231235
var relativePath = url.substring(appPrefix.length, paramsStart);
@@ -279,7 +283,7 @@ export class TestBrokerViewModel extends observable.Observable {
279283
}
280284

281285
private isTestScript(url: string): boolean {
282-
return url.startsWith('/base/app/tests/') || !url.startsWith('/base/app/');
286+
return url.startsWith(`/base/${config.options.appDirectoryRelativePath}/tests/`) || !url.startsWith(`/base/${config.options.appDirectoryRelativePath}/`);
283287
}
284288

285289
public updateBrowsersInfo(browsers) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-unit-test-runner",
3-
"version": "0.3.4",
3+
"version": "0.4.0",
44
"description": "NativeScript unit test runner component.",
55
"main": "app.js",
66
"scripts": {

0 commit comments

Comments
 (0)