Get help with testing, discuss unit testing strategies etc.


Post by zombeerose »

The preload option is not loading the specified JS file before launching each test. I don't even seen the file requested in network traffic. Here is the harness config:
var harness = new Siesta.Harness.Browser.ExtJS();

harness.configure({
    autoCheckGlobals: true,
    coverageUnit: 'file',
    defaultTimeout: 30000,
    enableCodeCoverage: false,
    expectedGlobals: [
        'Ext'
    ],
    forceDOMVisible: true,
    needDone: true,
    pauseBetweenTests: 500,
    preload: [
        '/includes/portal/tests/bootstrap.t.js'
    ],
    showTestDurationColumn: true,
    speedRun: true,
    testClass: Portal.TestClass,
    title: 'Portal Test Suite',
    transparentEx: false, 
    viewDOM: true, 
    waitForTimeout: 30000
});

harness.startFromUrl('/tests/unit/discover');

Any ideas? Does preload work when using "startFromUrl"?

Siesta 4.2.2 and 4.4.4.

Post by nickolay »

Hm.. Preload should definitely work. Perhaps test has its own "preload" config? Or it uses "pageUrl" config (in this case preload will be ignored by default)?

Post by zombeerose »

Indeed, that is the case that I overlooked. I was including the "pageUrl" in the startFromUrl response. I have updated the response and it works. Thanks!

One more question - during the preload (or before the test runs), is there a way to augment the Ext object such that the ajax responses can be manipulated? Essentially I want this code to run so I can redirect tests to local static data:
Ext.Function.interceptBefore(Ext.Ajax, 'request', function(options){ ... }

Post by nickolay »

Sure, just place this code in the test? There's SimManager IIRC - Ext ajax mocking in the examples.

Post by zombeerose »

Since this intercept would apply to a lot of tests (>100), I am looking for a universal way to inject it. I'll check the examples.

Post by nickolay »

Then probably you need your own test class with tweaked "setup" method.

Post Reply