lundi 25 septembre 2017

How to resolve a "define is not defined" error when using jasmine karma with compiled typescript to test a component?

I have a typescript app that has been compiled down to a single file, myjs.js in the js folder. And I have karma jasmine setup on my workspace.

in the myjs.js there is the code

var require, define, requirejs;
(function() {compiled typescript code here } )();
etc etc etc;

Somewhere inside my compiled typescript is the code

define('component/to/test', ["dependencies"], function(dependencies){ ... }

in my jasmine testscript, I have,

define([component/to/test], function(component){ jasmine specifications here} );

However, when running the jasmine file with karma start, I get the error that

define is not defined

I checked the karma config file, both files are included as js/.js and spec/.js .

Any idea what I am doing wrong, this is the first time doing something like this.

Aucun commentaire:

Enregistrer un commentaire