mercredi 29 juillet 2015

GitHub API throws error when I don't make any GitHub API calls

I have a website written with AngularJS that I have wrapped in end-to-end tests with Protractor. On this site, I have several links to GitHub repositories for said website. I have several end-to-end tests that click those links and verify that they take you to the correct page. I also have assertions at the end of each test that verifies that no javascript errors were thrown.

Occasionally, when the tests run, I see the following error in the test results:

<failure type="toBe" message="Expected 'http://ift.tt/1SixWpc 0:0 Fetch API cannot load http://ift.tt/1xS9Mbp. ' to be ''."><![CDATA[Error: Failed expectation
    at app.assertNoErrors (C:\Users\Cid the Coatrack\Documents\Programming\Projects\DNDGenSite\Tests\Integration\Views\commonTestFunctions.js:17:47)
    at [object Object].promise.ControlFlow.runInFrame_ (C:\Users\Cid the Coatrack\Documents\Programming\Projects\DNDGenSite\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1877:20)
    at [object Object].promise.Callback_.goog.defineClass.notify (C:\Users\Cid the Coatrack\Documents\Programming\Projects\DNDGenSite\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:2464:25)
    at [object Object].promise.Promise.notify_ (C:\Users\Cid the Coatrack\Documents\Programming\Projects\DNDGenSite\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:563:12)
    at Array.forEach (native)
    at Object.goog.array.forEach (C:\Users\Cid the Coatrack\Documents\Programming\Projects\DNDGenSite\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\array\array.js:203:43)
    at [object Object].promise.Promise.notifyAll_ (C:\Users\Cid the Coatrack\Documents\Programming\Projects\DNDGenSite\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:552:16)
    at goog.async.run.processWorkQueue (C:\Users\Cid the Coatrack\Documents\Programming\Projects\DNDGenSite\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:125:21)
    at runMicrotasksCallback (node.js:337:7)]]>
</failure>

This is particularly confusing because I am making no API calls to GitHub at all - I merely place hyperlinks on the page for the user to click:

<ul class="nav navbar-nav navbar-right">
    <li class="dropdown">
        <a id="collapsedGithubLinks" href="#" class="dropdown-toggle" data-toggle="dropdown">GitHub <span class="caret"></span></a>
        <ul class="dropdown-menu" role="menu">
            <li><a id="githubOrganizationLink" href="http://ift.tt/1SixYNV">The DnDGen Project</a></li>
            <li class="divider"></li>
            <li><a id="githubDiceLink" href="http://ift.tt/1JSC1Xl">RollGen</a></li>
            <li><a id="githubEquipmentLink" href="http://ift.tt/1SixWpf">TreasureGen</a></li>
            <li><a id="githubCharacterLink" href="http://ift.tt/1SixWpc">CharacterGen</a></li>
            <li><a id="githubEncounterLink" href="http://ift.tt/1JSC0T8">EncounterGen</a></li>
            <li><a id="githubDungeonLink" href="http://ift.tt/1SixWph">DungeonGen</a></li>
            <li><a id="githubSiteLink" href="http://ift.tt/1JSC1Xq">This Site</a></li>
        </ul>
    </li>
    <li class="padding-right"><a id="officialDndLink" href="http://dnd.wizards.com/">Official D&D Site</a></li>
</ul>

What is even stranger is that the test that fails is not consistent. Sometimes, all tests will pass. Other times, several tests will fail. And the tests that fail are not related to those links - sometimes tests asserting that the brand is shown in the navbar, with no relation or reference to the links at all, will fail for the same API reason.

I have yet to see this error ever occur on the live site. I want to know what is causing this to sporadically occur and how I can fix it.

Aucun commentaire:

Enregistrer un commentaire