Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handlers called twice because cleanup between tests is late #93

Open
RomkeVdMeulen opened this issue Oct 3, 2019 · 4 comments
Open

Comments

@RomkeVdMeulen
Copy link
Contributor

I'm submitting a bug report

  • Library Version:
    1.0.0

Please tell us about your environment:

  • Operating System:
    Linux (Ubuntu 18.04.3)

  • Node Version:
    8.16.1

  • NPM Version:
    6.8.0

  • JSPM OR Webpack AND Version
    JSPM 0.16.53

  • Browser:
    Chrome 77

  • Language:
    TypeScript 3.5.3

Current behavior:
When running a lot of tests, every so often I will get errors because an event handler (usually a click handler) that has been registered with click.delegate is called twice. I'm assuming this is because the handler registered in the preceeding test hasn't been cleaned up in time. I'm calling ComponentTester.dispose() in my tear down but it's not enough.

Expected/desired behavior:
If a test cannot be reliably cleaned up synchronously, ComponentTester.dispose() should return a promise that resolves when cleanup is complete. Most testing frameworks these days support returning a promise from a tear down and waiting for this to complete.

@bigopon
Copy link
Member

bigopon commented Oct 3, 2019

This is an issue in vCurrent with EventManager, that we don't have a teardown mechanism in EventManager. Though I think it should be easy to add, could you help with this?

@bigopon
Copy link
Member

bigopon commented Oct 3, 2019

Maybe the first thing is let's have a look at a repro. Could you help share one?

@RomkeVdMeulen
Copy link
Contributor Author

The difficulty is that this only seems to occur under heavy load. I'll see if I can put something together that will reliably show the error.

@RomkeVdMeulen
Copy link
Contributor Author

RomkeVdMeulen commented Oct 3, 2019

I've managed to put something together that shows a handler being called multiple times when it shouldn't be. In this case it's caused by aurelia-dialog and not click.delegate, but the principle is the same. I based it on the esnext skeleton since I wanted to base my reproduction on Karma.

https://github.com/RomkeVdMeulen/aurelia-testing-delegate-bug

To reproduce:

npm install
jspm install
gulp test

Note that problems occur in app.spec.js but not counter.spec.js.

@RomkeVdMeulen RomkeVdMeulen changed the title Delegated handlers not cleared between tests Handlers called twice because cleanup between tests is late Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants