Skip to content

Commit 98f30a7

Browse files
author
Dimitar Tachev
authored
Merge pull request #32 from NativeScript/tachev/fix-css-errors
fix: fix Qunit tests by avoiding css files evaluation
2 parents e1f6ab4 + a23388a commit 98f30a7

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

main-view-model.ts

+22-13
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ export class TestBrokerViewModel extends observable.Observable {
103103
method: 'GET',
104104
timeout: 3000,
105105
}).then(() => {
106-
console.log('NSUTR: found karma at ' + ip);
107-
if (!foundKarma) {
108-
foundKarma = true;
109-
resolve(ip);
110-
}
111-
}, () => undefined)
106+
console.log('NSUTR: found karma at ' + ip);
107+
if (!foundKarma) {
108+
foundKarma = true;
109+
resolve(ip);
110+
}
111+
}, () => undefined)
112112
});
113113
Promise.all(resolvers)
114114
.then(() => {
@@ -231,7 +231,7 @@ export class TestBrokerViewModel extends observable.Observable {
231231
return Promise.all(scriptUrls.map((url): Promise<IScriptInfo> => {
232232
var appPrefix = `/base/${config.options.appDirectoryRelativePath}/`;
233233
if (url.startsWith(appPrefix)) {
234-
var paramsStart = url.indexOf('?');
234+
var paramsStart = url.lastIndexOf('?');
235235
var relativePath = url.substring(appPrefix.length, paramsStart);
236236
return Promise.resolve({
237237
url: url,
@@ -260,12 +260,21 @@ export class TestBrokerViewModel extends observable.Observable {
260260
console.log('NSUTR: require script ' + script.url + ' from ' + script.localPath);
261261
require(script.localPath);
262262
} else {
263-
console.log('NSUTR: eval script ' + script.url);
264-
this.loadShim(script.url);
265-
//call eval indirectly to execute the scripts in the global scope
266-
var geval = eval;
267-
geval(script.contents);
268-
this.completeLoading(script.url);
263+
const queryStringStart = script.url.lastIndexOf('?');
264+
const pathWithoutQueryString = script.url.substring(0, queryStringStart);
265+
const extensionRegex = /\.([^.\/]+)$/;
266+
const fileExtension = extensionRegex.exec(pathWithoutQueryString)[1];
267+
268+
if (!fileExtension || fileExtension.toLowerCase() === "js") {
269+
console.log('NSUTR: eval script ' + script.url);
270+
this.loadShim(script.url);
271+
// call eval indirectly to execute the scripts in the global scope
272+
var geval = eval;
273+
geval(script.contents);
274+
this.completeLoading(script.url);
275+
} else {
276+
console.log('NSUTR: ignoring evaluation of script ' + script.url)
277+
}
269278
}
270279
} catch (err) {
271280
this.error(err.toString(), script.localPath || script.url, err.lineNumber || 0);

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.5.0",
3+
"version": "0.5.1",
44
"description": "NativeScript unit test runner component.",
55
"main": "app.js",
66
"scripts": {

0 commit comments

Comments
 (0)