title: Calling trigger() doesn't always fire when called from QUnit
body: <p>Although I've used QUnit in the past, it's been a year since I really used it, so I am hoping this is something trivial!</p>
  
  <p>I have a bunch of QUnit tests that are working really well, apart from one that fails every other time that the page is loaded. If I refresh, the test works, but if I refresh again it breaks! It's become predictable but I cannot see why it's not working. The test in question should use a <code>trigger('change')</code> event, but this only fires every other time.</p>
  
  <p>I have a dynamically populated <code>select</code> that I bind a <code>change</code> event to. All that it does it save the value to <code>localStorage</code> and the test I have just checks the value has been set.</p>
  
  <p>Example HTML:</p>
  
  <pre><code>&lt;select id="options"&gt;
      &lt;option value=""&gt;Please choose&lt;/option&gt;
  &lt;/select&gt;
  &lt;p id="result"&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Example JS:</p>
  
  <pre><code>$(document).ready(function() {
      var data = {
          1: 'Option 1',
          2: 'Option 2',
          3: 'Option 3'
      }
      for(var d in data) {
          $('#options').append($('&lt;option&gt;').val(d).text(data[d]));
      }
      $('#options').on('change', function() {
          $('#result').text(this.value);
          if(this.value != '') {
              localStorage.setItem('optionValue') = this.value;
          } else {
              throw 'You must choose a team';
          }
      });
  });
  </code></pre>
  
  <p>Example QUnit tests:</p>
  
  <pre><code>test('Test some other stuff', function(assert) {
      localStorage.removeItem('optionValue');
      // some tests to check things have worked correctly
  });
  
  test('Is value added to localStorage?', 2, function(assert) {
      throws(function() { throw new $('#chooseTeam').val('').change(); }, 'No option selected');
      $('#options').val(1).trigger('change');
      equal(localStorage.getItem('optionValue'), 1, 'The first item should be selected');
  });
  </code></pre>
  
  <p>However, the result in the QUnit output is <code>undefined</code>. I narrowed it down to the first test and then was able to see that it's the line <code>localStorage.removeItem('optionValue')</code> that is called every time but the change event is only triggered every other time.</p>
  
  <p>I've create a JS fiddle to try and demonstrate the problem: <a href="http://jsfiddle.net/cchana/zqNtU/3/" rel="nofollow">http://jsfiddle.net/cchana/zqNtU/3/</a> (the demo shows how it should work, but not the failing tests)</p>
  
  <p>Is there something obvious that would make this fail anyway?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Thought I should update with some information that may help...</p>
  
  <p>In the change method, I added a <code>console.log()</code>, like so:</p>
  
  <pre><code>$('#options').on('change', function() {
      console.log('here');
  });
  </code></pre>
  
  <p>I just wanted to check that the change event was actually being triggered, but just as the tests show, the method is only triggered every other time.</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>To get my tests passing, I have removed the line <code>localStorage.removeItem('optionValue');</code> not ideal and I would still like to get to the bottom of it if at all possible!</p>