Skip to content

Commit 2d377fc

Browse files
committed
shims for mocha and chai
1 parent d63a73e commit 2d377fc

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

main-view-model.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ export class TestBrokerViewModel extends observable.Observable {
246246
//call eval indirectly to execute the scripts in the global scope
247247
var geval = eval;
248248
geval(script.contents);
249+
this.completeLoading(script.url);
249250
}
250251
});
251252

@@ -333,6 +334,21 @@ export class TestBrokerViewModel extends observable.Observable {
333334
if (!global.document.getElementById) {
334335
global.document.getElementById = id => null;
335336
}
337+
} else if (url.indexOf('chai') !== -1) {
338+
global.__shim_require = global.require;
339+
global.require = function() {
340+
throw Error();
341+
}
342+
343+
global.window = global;
344+
}
345+
}
346+
347+
private completeLoading(url: string) {
348+
if (url.indexOf('chai') !== -1) {
349+
delete global.window;
350+
global.require = global.__shim_require;
351+
delete global.__shim_require;
336352
}
337353
}
338354
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-unit-test-runner",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "NativeScript unit test runner component.",
55
"main": "app.js",
66
"scripts": {

0 commit comments

Comments
 (0)