Question

I'm trying to see whether a popup is shown after a certain action. The popup is done with pnotify and puts a div.ui-pnotify in the DOM. I can see the notification popping up in the tests, but I can't seem to test it's visibility with QUnit, most probably because of a delay. Anybody here with experience in this area?

ok(find('div.ui-pnotify').length, 'Name has been changed');

Chrome console:

<div class="ui-pnotify " style="width: 300px; right: 25px; top: 25px; opacity: 1; display: block; cursor: auto;"><div class="alert ui-pnotify-container alert-success ui-pnotify-shadow" style="min-height: 16px;"><div class="ui-pnotify-icon"><span class="fa fa-check"></span></div><div class="ui-pnotify-closer" style="cursor: pointer; visibility: hidden;"><span class="fa fa-times"></span></div><div class="ui-pnotify-sticker" style="cursor: pointer; visibility: hidden;"><span class="fa fa-play"></span></div><h4 class="ui-pnotify-title">Persoonlijke gegevens</h4><div class="ui-pnotify-text">Uw persoonlijke gegevens zijn opgeslagen.</div></div></div>
Was it helpful?

Solution

I'm not familiar with find(), unless you're using this, which won't work for various reasons. However, this test works for me:

QUnit.test('example', function () {
    ok($('div.ui-pnotify').length, 'Name has been changed');
});

JSFiddle

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top