Skip to content

feat: respect nsconfig file from project and correctly navigate to run tests page #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app-root.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<Frame defaultPage="./tns_modules/nativescript-unit-test-runner/main-page">
<Frame defaultPage="./tns_modules/nativescript-unit-test-runner/main-page" id="root-frame">
</Frame>
14 changes: 9 additions & 5 deletions main-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface IHostConfiguration {
options: {
debugBrk?: boolean;
debugTransport?: boolean;
appDirectoryRelativePath?: string;
}
}

Expand Down Expand Up @@ -42,7 +43,10 @@ function enableSocketIoDebugging() {
}

var config: INetworkConfiguration = require('./config');
config.options = config.options || {}
config.options = config.options || {};
if (!config.options.appDirectoryRelativePath) {
config.options.appDirectoryRelativePath = "app";
}

export class TestBrokerViewModel extends observable.Observable {
private startEmitted: boolean;
Expand Down Expand Up @@ -189,13 +193,13 @@ export class TestBrokerViewModel extends observable.Observable {
}

public viewTestRunDetails() {
frameModule.topmost().navigate('run-details');
frameModule.getFrameById('root-frame').navigate('run-details');
}

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

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

public onKarmaExecute(cfg) {
Expand Down Expand Up @@ -225,7 +229,7 @@ export class TestBrokerViewModel extends observable.Observable {
})
.then(scriptUrls => {
return Promise.all(scriptUrls.map((url): Promise<IScriptInfo> => {
var appPrefix = '/base/app/';
var appPrefix = `/base/${config.options.appDirectoryRelativePath}/`;
if (url.startsWith(appPrefix)) {
var paramsStart = url.indexOf('?');
var relativePath = url.substring(appPrefix.length, paramsStart);
Expand Down Expand Up @@ -279,7 +283,7 @@ export class TestBrokerViewModel extends observable.Observable {
}

private isTestScript(url: string): boolean {
return url.startsWith('/base/app/tests/') || !url.startsWith('/base/app/');
return url.startsWith(`/base/${config.options.appDirectoryRelativePath}/tests/`) || !url.startsWith(`/base/${config.options.appDirectoryRelativePath}/`);
}

public updateBrowsersInfo(browsers) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-unit-test-runner",
"version": "0.3.4",
"version": "0.4.0",
"description": "NativeScript unit test runner component.",
"main": "app.js",
"scripts": {
Expand Down