This is a migrated thread and some comments may be shown as answers.

kendo* is not a function while running karma/jasmine/phantomjs

3 Answers 69 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 05 Jan 2017, 06:33 PM

Trying to run some unit tests of our Kendo components which are wrapped in Marionette Views and am getting a "kendoGrid is not a function" error, and am not sure why.

The kendo global is attached to window, and all the kendo* functions do come up as undefined in the debugger.

Here is the load order from the body of the karma debugger:

<script type="text/javascript" src="/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="/base/node_modules/karma-jasmine/lib/boot.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="/base/node_modules/karma-jasmine/lib/adapter.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="/base/web-libs-common/src/main/resources/META-INF/resources/static/js/lib/jquery/jquery.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="/base/web-libs-common/src/main/resources/META-INF/resources/static/js/lib/kendoui/kendo.all.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="/base/node_modules/requirejs/require.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="/base/node_modules/karma-requirejs/lib/adapter.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="/base/test-main.js" crossorigin="anonymous"></script>

 

jQuery does not get loaded twice, BUT setting a break point in one of the tests and then inspecting it shows another jQuery script tag in the head element which is gone after all the tests run/blow up.

My karma.conf.js, test-main.js, and require.js config are here if needed:
StackOverflow Post

Any help would be greatly appreciated!

3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 09 Jan 2017, 11:51 AM

Hi Ryan,

The second jQuery <script> tag that you have observed is the most likely reason for the problem: http://docs.telerik.com/kendo-ui/troubleshoot/troubleshooting-common-issues#widgets-are-unavailable-or-undefined.

At this point the only suggestion I can make is that you try moving the jquery reference further up in the test file, before Kendo and other jQuery widgets like jQueryUI.


Regards,

Marin Bratanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Ryan
Top achievements
Rank 1
answered on 09 Jan 2017, 08:46 PM
That's pretty much what I figured, but thought it wouldn't hurt to check--thanks!
0
Marin Bratanov
Telerik team
answered on 10 Jan 2017, 10:22 AM

Hi Ryan,

I hope you will be able to resolve the situation. If you do, I believe the community will be grateful if you post your solution either here, or in StackOverflow.

Regards,

Marin Bratanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
Ryan
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or