question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flaky tests for focusout

See original GitHub issue

I am not sure what this all means, but given a component that listens for focusout I get these results:

  • this.$('input').trigger('focusout') always works
  • this.$('input').trigger('blur') always works
  • triggerEvent('input', 'focusout') never works
  • triggerEvent('input', 'blur') always works
  • blur('input') sometimes works

I created a reproduction repo here: https://github.com/simonihmig/ember-native-helpers-demo/blob/master/tests/integration/components/foo-bar-test.js

Regarding the blur flakiness: it seems it does work when having a fresh test run, or pressing enter on ember t -s:

image

As soon as I reload the Chrome browser window, the test fails:

image

Seems related to the browser-has-focus handling in blur.js: as soon as it hits this line (https://github.com/cibernox/ember-native-dom-helpers/blob/master/addon-test-support/blur.js#L32) it seems to work. I patched that helper locally to always call fireEvent and not el.blur(), and then it seems to work just fine for me.

Don’t know if that makes sense? Also why triggerEvent('input', 'focusout') does not work at all…

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RuslanZavackycommented, May 3, 2017

ah, yea, @simonihmig it’s actually the thing 😃 If you try to do blur, without focusing into element first, it’s not exactly how the browser works, when the user interacts with it 😃 so in tests, you have to mimic the similar behavior. Before blurring, you have to be focused on an element.

0reactions
simonihmigcommented, May 3, 2017

Yeah, makes sense! I was just naively assuming what was working with jQuery events would work the same with native events…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Some tests flake only if test runner's browser loses focus (or ...
I am experiencing something like this related to the focusout event. If the browser window has focus while the test is running, it...
Read more >
Flaky tests - JVM Advent
The flaky test is a test that is sometimes green and sometimes red – without changing AUT (application under test). It's really bad...
Read more >
Cross Browser Compatibility Score of focusin & focusout events
Perform browser compatibility test for focusin & focusout events and many more web technologies that are a part of your website or ...
Read more >
How to Fix Flaky Tests - Semaphore CI
Flaky tests hinder development, slow down progress, hide design problems, and can cost a lot of money in the long run.
Read more >
Flaky tests - GitLab Documentation
Flaky tests. What's a flaky test? It's a test that sometimes fails, but if you retry it enough times, it passes, eventually.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found