Вопрос

I'm having a crack at using DalekJS as a way to debug both UI and JS sides of a library I'm working on.

I have a html page which loads in some js files as follows:

<script src="./../../../app/scripts/focusable-item.js"></script>
<script src="./../../../app/scripts/focus-controller.js"></script>
<script src="./../../../app/scripts/generic-focusable-item.js"></script>
<script src="./../../../app/scripts/main.js"></script>

Then in my tests, I would just like to ensure these are accessible from the page, for example:

'Test FocusController is loaded': function (test) {
    test
        .open('http://localhost:9000/grid-left-top.html')
        .execute(function () {
            try {
                new FocusController();
            } catch (exception) {
                this.assert.ok(false, 'Failed to create a FocusController: ['+exception+']');
                return;
            }

            this.assert.ok(true);
        })
        .done();
}

I'm always getting an exception that the variables FocusController can't be found, but the page loads fine when loaded manually in Chrome and Firefox, does anyone have any idea's on the following:

  • Should I wait for the page to load fully? If so how?
  • Are there any known gotchas when using PhantomJS in terms of JS support?
  • Any guidance on how to debug this further?

Cheers, Matt

Это было полезно?

Решение

Figured out my issue was one with set of a grunt file and the test server it kicked off.

Essentially the js files couldn't be found, I figured it out by running the test server and loading the page through that rather than load the html file into the browser.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top