Discuss anything related to web development but no technical support questions


Post by klodoma »

How can you enable/see the code-coverage for non-extjs files?
The code-coverage for extjs files works well.

Now, I want to test some simple prototype functions like:

file: /js/common/Prototypes.js
if ( !String.prototype.capitalizeFirst ) {
    String.prototype.capitalizeFirst = function ()
    {
        return this.charAt( 0 ).toUpperCase() + this.slice( 1 );
    };
}
with:
StartTest( function ( t )
{
    t.it( "String.prototype.capitalizeFirst", function ( t )
    {
        t.is( "aaa".capitalizeFirst(), "Aaa" );
        t.is( "baa".capitalizeFirst(), "Baa" );
    } );

} );
The test is working, but I can't get the code coverage.

Configs:
var harness = new Siesta.Harness.Browser.ExtJS();

harness.configure( {
    title: 'Interpid Test Suite',
    viewDOM: true,

    enableCodeCoverage: true,
    //coverageUnit: 'extjs_class', // can be "file" or "extjs_class"
    coverageUnit: 'file', // can be "file" or "extjs_class"

    // Define any global JS and CSS dependencies, these files will be injected into each test.
    preload: preloadsExt5,

    // If your tests use dynamic loading, you can setup your paths using the 'loaderPath' config.
    loaderPath: {
        'Ipd': BASE_URL + '/js/ipd',
        'Ext.ux': BASE_URL + '/vendor/js/extjs-ux/6.5.0'
    }
} );


harness.start(
    {
        group: 'Ipd',
        items: [
            {
                group: 'Prototypes',
                items: [
                    {
                        preload: [
                            BASE_URL + '/js/common/Prototypes.js'
                        ],
                        url: 'prototype/String.t.js'
                    }
                ]
            },
...


Post by nickolay »

Need to supply the "instrument : true" flag in the preload descriptor:
preload: [
    {
        url         : BASE_URL + '/js/common/Prototypes.js',
        instrument  : true
    }
],

Post by klodoma »

Cool! Thanks!

Post by Alizeh »

I was also facing the same problem earlier. Now my problem is solved. Thanks again. :)

Post by tocnaza »

Great code! Thanks for sharing us!

Post by nikhil.bhatia »

This does not work with the new release of Siesta (5.1.0).

Post Reply