cypress-plugin-tab icon indicating copy to clipboard operation
cypress-plugin-tab copied to clipboard

Does not work properly if test browser has focus?

Open esamattis opened this issue 6 years ago • 2 comments

Hi!

I created few tests for @valu/focus-trap using this. Unfortunately it seems that it does not work quite right if tests are executed with window focus.

Steps to reproduce:

git clone [email protected]:valu-digital/focus-trap.git
cd focus-trap/
git checkout 82863d8024d1d061de8d5a0a200babb8293d8739
npm ci

Start server in another shell

npm run examples-dev

Open Cypress

npm run cypress

Hit "Run all specs" and observe how bunch of the tests fail.

image

Next open cypress/integration/focus-trap.spec.ts and edit some test name and hit save, live reload should trigger test rerunning and now observe how all tests pass.

image

I'm sometimes able to make tests pass when pressing this re-run button

image

but not always. Not sure why. The live reload is the only way I'm able make them pass consistently.


Any ideas what might be going on?

@valu/focus-trap works by tapping into the focusin event, calls stopImmediatePropagation() on it and programmatically focuses elements it wants with .focus(). The most relevant code here is here

https://github.com/valu-digital/focus-trap/blob/82863d8024d1d061de8d5a0a200babb8293d8739/src/index.ts#L283


Anyway thank you for creating this! This is the only tool I've been able to create any tests for library like this. Cheers!

esamattis avatar Oct 16 '19 15:10 esamattis

@epeli awesome, thanks for the reproducible. I'll take a look

kuceb avatar Oct 16 '19 18:10 kuceb

Any updates on this? I'm facing this too :/

mikaelboff avatar Jun 30 '20 04:06 mikaelboff