Get help with testing, discuss unit testing strategies etc.


Post by AaronTovo »

I'm getting a series of errors that say
Uncaught Error: Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. Missing required class: JVES.view.Header
I have enabled the loader in my app.js file where my Ext.application() is defined:
Ext.Loader.setConfig({
    enabled: true,          
    disableCaching: true
});
My Harness config looks like

var Harness = Siesta.Harness.Browser.ExtJS;

Harness.configure({
    title       : 'Awesome Test Suite',
    loaderPath  : { 'JVES' : 'j-ves' },
    waitForAppReady: false,
    expectedGlobals: [
        'Ext',
        'VI',
        'TR'
    ],
    preload     : [
        "siesta-test/lib/ext4/resources/vitaltheme/css/vitaltheme.css",
        "siesta-test/lib/ext4/ext-all-debug.js",
        "siesta-test/lib/ext4/locale/ext-lang-en.js",
        "j-ves/Utils.js" 
        ]
});

Harness.start(
    {
        hostPageUrl: 'jves',      
        url: 'siesta-test/010_sanity.t.js'
    },
    'siesta-test/020_basic.t.js',
    {
        hostPageUrl: 'jves',
        url: 'siesta-test/030_archive.t.js'
    }
);
I don't see anything about enabling the Ext.Loader in the Siesta documentation except for the bit about setting "loaderPath : { 'JVES' : 'j-ves' }".

in my code the directory structure looks like
/j-ves
    /model
    /store
    /view
    /controller
and the class names look like Ext.define('JVES.view.Header', {...}).

How do I enable dynamic loading within each test?

Post by nickolay »

One note - when using "hostPageUrl" the "preload" option is still active. This means that along with any files listed in your "hostPageUrl" page siesta will additionally load the files from "preload". Thats probably not what you want - try to empty the preloads for those tests:
Harness.start(
    {
        group       : 'Tests on app page',
        
        hostPageUrl : 'jves',
        preload     : [], // don't load any additional files, assume everything is loaded by page
        
        items       : [
            'siesta-test/010_sanity.t.js',
            'siesta-test/030_archive.t.js'
        ]
    },
    'siesta-test/020_basic.t.js'
);
About your question - in your "j-ves/Utils.js" do you have a class that requires "JVES.view.Header"? If so, try enabling the Ext.Loader before "j-ves/Utils.js":
Harness.configure({
    ...
   
    preload     : [
        "siesta-test/lib/ext4/resources/vitaltheme/css/vitaltheme.css",
        "siesta-test/lib/ext4/ext-all-debug.js",
        "siesta-test/lib/ext4/locale/ext-lang-en.js",
        {
            text        : 'Ext.Loader.setConfig({ enabled : true, path : "XXX" })'
        },
        "j-ves/Utils.js"
    ]
});
Need to also provide a path for it, because "loaderPath" config will be applied _after_ all preloads.

Post by flintg »

My problem was that I first did not have the Loader enabled, so after getting the error, I added the code to enable the loader. But then, I still received the error.

What eventually resolved this issue for me was clearing the cache in my browser. Using Firefox, I've noticed that even a Ctl+F5 doesn't force a reload of everything (for instance, when I make changes in my source app), and I still have old code hanging around. By clearing the cache before each test, the browser must request each resource again.

To clear the cache in Firefox, go to Tools -> Options -> Advanced and press the "Clear Now" button in the "Cached Web Content" group.

HTH

Post by jakub »

Tip for you, you can turn off caching completely in about::config .
Last edited by jakub on Tue Jun 26, 2012 9:38 am, edited 1 time in total.
JavaScript/Angular/ExtJS consulting - kuba@virtualdesign.pl

Post by flintg »

Thank you for the tip! Use [url]about:config[/url] for later versions of Firefox (I'm on 14.0, now). Disabling the network.http.use-cache, and browser.cache.disk.enable config options seems to have done the trick. One caveat though is that Firebug is not as sensitive to these options as Firefox, so you could see multiple copies of source files after doing a Ctrl+F5 refresh.

Post Reply