Get help with testing, discuss unit testing strategies etc.


Post by zombeerose »

I am trying to setup the trial but I am encountering errors, which I believe are related to the location of my source files. Is it possible to specify the source folder, similar to the appFolder config of the Ext.app.Application class?

Below is my folder structure:
htdocs
-includes
--library
---extjs
----ext
----myproduct
-----tests
-----* 010_sanity.t.js
-----* 020_basic.t.js
-----* index.js
---siesta

Below is the contents of my index.js:
var Harness = Siesta.Harness.Browser.ExtJS,
    testRoot = '/includes/library/extjs/myproduct/tests/';

Harness.configure({
    title       : 'My Test Suite',

    //all paths are relative to this file
    preload     : [
        '../../ext/resources/css/ext-all.css',
        '../../ext/ext-all.js'
    ]
});

Harness.start(
    testRoot+'010_sanity.t.js'
);
When running in FF 8.0, I receive the following error in Siesta:
Passed: 0
Failed: 0
Test suite threw an exception: Error loading script https://mydomain/ext/ext-all.js 1
I am also getting the following 404's in firebug:
"NetworkError: 404 Not Found - https://mydomain/ext/resources/css/ext-all.css"
"NetworkError: 404 Not Found - https://mydomain/ext/ext-all.js"
Last edited by zombeerose on Wed Dec 07, 2011 5:29 pm, edited 1 time in total.

Post by zombeerose »

I changed my preload paths to absolute urls and the test ran successfully. So I guess it's just a question of whether a root path can be specified. Thanks

Post by nickolay »

Preload paths are relative to your harness page (index.html usually). In your folder structure there's a "extjs" dir and in preloads its just "ext" - typo?

Post by zombeerose »

Nope not a typo. I forgot to add 'ext' to my folder structure. I updated the original post.

I will also mention that we use Zend Framework for server development. The current pattern is to define the html (actually phtml) files thru Zend, which means that the html files are not directly web-accessible. It also means that the js and html are in totally different directory trees.

Post by nickolay »

Ok, I guess you've found the "hostPageUrl" option (note that "preload" will still be in effect).

Post by zombeerose »

Hmmm...so is hostPageUrl appended to the test item URLs? Does hostPageUrl get used in conjunction with the preload paths? I'm not sure how to use it ... my attempts have not been successful.

Post by nickolay »

`hostPageUrl` will be an initial "src" for your test page. It should point to a html page, which can contain arbitrary content (and can be generated by php script). Siesta then will add the javascript test file, and execute the tests. Something like this:
Harness.start(
{
  hostPageUrl    : '../../my_php_script?page=home',  // point to html page
  url                   : '010_home_page_d_n_d.t.js'  // point to regular test file (with StartTest() etc)
},
...

)
Updated the docs for this option.

Post Reply