KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a two tests that are causing side effects with each other. I understand why as I am replacing a jQuery built-in function that is being called internally in the second test. However what I don't understand is why the test alternately passes and fails. This question is similar However, I am not doing anything directly on the qunit-fixture div. Here are my tests test('always passing test', function() { // Always passes var panelId = '#PanelMyTab'; var event = {}; var ui = { tab: { name: 'MyTab', }, panel: panelId, }; $('<div id="' + panelId + '">') .append('<a href="#" class="export">Test</a>') .append('<a href="#" class="showForm">Show Form</a>') .appendTo('#qunit-fixture'); jQuery.fn.on = function(event, callback) { ok(this.selector == panelId + ' .export', 'Setting export click event'); equal(callback, tickets.search.getReport, 'Callback being set'); }; loadTab(event, ui); }); test('alternately passing and failing', function() { // Alternates between passing and failing on page refresh expect(5); var testUrl = 'test'; $('<div class="ui-tabs-panel">') .append('<a href="'+ testUrl + '" id="getReport">Get Report</a>') .append('<form action="notest" target="" class="ticketSearch"></form>') .appendTo('#qunit-fixture'); // Setup form mocking $('form.ticketSearch').submit(function() { var urlPattern = new RegExp(testUrl + '$'); ok(urlPattern.test($(this).prop('action')), 'Form action set to link href'); equal($(this).prop('target'), '_blank', 'Open form on a new page'); }); var event = { target: 'a#getReport', }; var result = getReport(
Tags (comma-separated)
Save Edits
Cancel