Search code examples
ember.jsintegration-testingqunitember-qunit

Testing visibility of an element


I'm writing integrations tests for an Ember app using QUnit. Is there anyway to test if an element is visible?

My experience with integration testing comes from Capybara which detects only visible elements by default.


Solution

  • If you have HTML fixture as described in the guide you should be able to check the elements using jQuery:

    test( "search, close", function() {
        //SNIP
        // Note the use of a real element here:
        element = $( "#autocomplete" ).autocomplete({
            source: data,
            minLength: 0
        }),
        menu = element.autocomplete( "widget" );
        //SNIP
        ok( menu.is( ":visible" ), "menu is visible after search" );
        //SNIP
    });
    

    Code source: Test for visible in QUnit test of JQueryUI widget