Get help with testing, discuss unit testing strategies etc.


Post by bperel »

Hello,

I am trying to set up code coverage for our Siesta tests, using Siesta 4.4.2.

The following command runs successfully:
bin/webdriver https://www.myproject.local:8080/dist/tests --cap browser=firefox --cap os=windows --cap os_version=XP --coverage-report-format=html+raw --headless
It generates a few files in ./coverage :

coverage-data.json
index.html
raw_coverage_data.json
siesta-coverage-report.js

When launching index.html in my browser, I only get a page with a dark gray background and a JS error:
TypeError: this.msgTextEl is null
The generated index.html has the following contents:
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

    <link rel="stylesheet" type="text/css" href="css/siesta-coverage-report.css">

    <script type="text/javascript" src="siesta-coverage-report.js"></script>

    <script type="text/javascript">
        Ext.onReady(function () {
            new Ext.Viewport({
                layout : 'fit',
                items  : {
                    xtype      : 'coveragereport',
                    standalone : true,
                    dataUrl    : 'coverage-data.json'
                }
            });
        });

    </script>
</head>
<body>
</body>
</html>
What did I do wrong?

Screenshot with stacktrace is in the attachments along with the contents of coverage-data.json, along with the harness source code (index.js).

Thank you in advance for your answer,
Attachments
index.js.txt
harness source code
(543 Bytes) Downloaded 209 times
coverage-data.json.txt
(5.88 KiB) Downloaded 224 times
Bruno

Post by nickolay »

Hi,

Do you open the report using web link (https://) or a file system link (file://)? Need to use the 1st, because it loads the report data using XHR and XHR to file system is restricted.

Also, I noticed that your tests uses "pageUrl" option. Please note, that code coverage support for such tests is limited to only the files, loaded dynamically, using Ext.require() or as dependencies for other classes. The required setup is here: https://www.bryntum.com/docs/siesta/#!/ ... tationHook (see the 2nd section "Or, when using Siesta.Harness.pageUrl option:")

Post by bperel »

Hi Nickolay, thank you for your answer.

I'm afraid I don't understand your suggestions.

I added :
<script type="text/javascript">
    parent.harness && eval(parent.harness.getLoaderInstrumentationHook())
</script>
in the source code of tests/index.html (before loading index.js) but I still get the same error. I'm a bit confused by the references to ExtJS in the documentation since I don't load this library at all in my tests.

Please enlighten me :-)
Bruno

Post by nickolay »

Oh, you don't use ExtJS. I'm afraid, the code coverage for "pageUrl" tests is only supported for on-demand loading in ExtJS (using loader hook) currently. We plan to improve this in the future releases.

Right now then, you can only get the coverage information for the unit tests (not using "pageUrl").

Post by bperel »

Ah alright, thanks for the answer. I'll check the next releases' changelogs then.
Bruno

Post Reply