PDA

View Full Version : Automated ExtJS testing using Jasmine and PhantomJS



SYZ
5 Nov 2012, 12:09 AM
Hi All,

I'm trying to use Jasmine + PhantomJS to automate ExtJS testing on my CI server. I've looked through Authur's post (http://www.sencha.com/blog/automating-unit-tests/) and his examples work fine. However, when I followed the ExtJS Doc here http://docs.sencha.com/ext-js/4-1/#!/guide/testing I have problems:

When I open the Jasmine tests in a browser, it works fine. However, when I run it in PhantomJS, I get the following errors.

39800

I compared the difference between the two projects and I suspect the error was thrown because of the run-test.html file in ExtJS Doc example. It directly calls "app-test.js" without including the following code in the <body> (which is present in the run-spec.html in Arthur's example)


<script type="text/javascript"> (function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;


var htmlReporter = new jasmine.HtmlReporter();


jasmineEnv.addReporter(htmlReporter);


jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};


var currentWindowOnload = window.onload;


window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};


function execJasmine() {
jasmineEnv.execute();
}


})();
</script>

I tried to add these code in my html but it failed to load the ExtJS project. Can any one show me how to do it and run via PhantomJS properly?

Thanks a lot!

SYZ
5 Nov 2012, 1:51 AM
Hi guys,

I think I have found the problem.


<script type="text/javascript" src="/ext-4/ext-all.js"></script>

In the HTML file, when adding the ExtJS library, initially I added ext-debug.js and PhantomJS was throwing errors. When I changedto ext-all.js, it was fine...

I'm a bit confused. Currently in Ext 4.1 there are the following files:
39809

What are the differences?

cwtuan
21 Apr 2014, 9:19 PM
it doesn't help for changing ext-all.js

ClaudeG
22 Jul 2014, 8:53 AM
See these repos I wrote: https://github.com/cgauthier/karma_jasmine_2_extjs4 and https://github.com/cgauthier/karma_jasmine_1_extjs4