简体   繁体   中英

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.

Found the problem. I forgot to do karma run after karma start.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM