ember-test-helpers icon indicating copy to clipboard operation
ember-test-helpers copied to clipboard

Regression: DOM helpers no longer wait on test waiters unless `ember-test-helpers/wait` is imported

Open kybishop opened this issue 7 years ago • 9 comments

I have been attempting to upgrade ember-attacher to ember 3.2 and beyond, but my tests started failing with the new test framework.

Previously, calls on await click('.stuff') would wait until all registered test waiters were settled. It appears this is no longer the case. Additionally, merely importing, not using, ember-test-helpers/wait (import wait from 'ember-test-helpers/wait';) causes tests in that file to pass again. From my sleuthing, importing wait registers the test waiters appropriately.

Thanks!

kybishop avatar Jul 27 '18 22:07 kybishop

I’m generally not aware of a general issue like this (and haven’t seen/heard of others with the same symptoms), thanks for reporting!

How can we reproduce? Without some sort of reproduction, I believe this will be somewhat difficult to diagnose...

rwjblue avatar Jul 27 '18 23:07 rwjblue

I've run into a similar issue with updating to ember 3.3 (from 3.1) and our usage of https://github.com/html-next/vertical-collection

If I await pauseTest() and resume inside the browser the tests will always pass. If I do await wait() its very inconsistent about tests passing, as it seems the tests will often run before the waiter has resolved

Following the path of their waiter https://github.com/html-next/vertical-collection/blob/master/tests/test-helper.js#L10 leads me to https://github.com/html-next/ember-raf-scheduler/blob/master/addon-test-support/register-waiter.js

but this seems to be an old way of registering a waiter. Is there a newer way? this may be the issue (for this particular library at least)

I'll try and pare down my code to something that can be shared as a reproducible example.

Slack conversation where this started: https://embercommunity.slack.com/archives/C0ASUJT3M/p1532452536000607

Frozenfire92 avatar Jul 30 '18 12:07 Frozenfire92

Can y’all share the output of:

npm ls @ember/test-helpers
npm ls ember-qunit
npm ls ember-cli-qunit 

rwjblue avatar Jul 30 '18 12:07 rwjblue

npm ls @ember/test-helpers
...path...
└─┬ [email protected]
  └─┬ [email protected]
    └── @ember/[email protected]
npm ls ember-qunit
...path...
└─┬ [email protected]
  └── [email protected]
npm ls ember-cli-qunit
...path...
└── [email protected]

Frozenfire92 avatar Jul 30 '18 13:07 Frozenfire92

[email protected] requires at least @ember/[email protected] (but you should just update to latest). Specifically, you need https://github.com/emberjs/ember-test-helpers/pull/366.

My guess is that your lock file just needs to be updated to get the updates. You could do:

# gets all allowed transitive dependency updates
yarn upgrade 

or

# gets only the transitive deps under ember-cli-qunit
yarn remove ember-cli-qunit
yarn add -D ember-cli-qunit

rwjblue avatar Jul 30 '18 14:07 rwjblue

Thanks for the help @rwjblue! definitely helped me come to a resolution

  1. I don't think ember-source depends on the test helpers. Looking at package.json so ensuring updating that didn't solve
  2. I just ran yarn or yarn install which I found out won't update packages to newer resolutions

Looking in the yarn lock I was quite confused why it never went to the latest verison

ember-qunit@^3.3.2:
  version "3.3.2"
  resolved "https://registry.yarnpkg.com/ember-qunit/-/ember-qunit-3.3.2.tgz#cb48e9deaffa3b4c90983f28c5cf8590894c8ea3"
  dependencies:
    "@ember/test-helpers" "^0.7.18"
    broccoli-funnel "^2.0.1"
    broccoli-merge-trees "^2.0.0"
    common-tags "^1.4.0"
    ember-cli-babel "^6.3.0"
    ember-cli-test-loader "^2.2.0"
    qunit "^2.5.0"
"@ember/test-helpers@^0.7.18":
  version "0.7.20"
  resolved "https://registry.yarnpkg.com/@ember/test-helpers/-/test-helpers-0.7.20.tgz#488b1c8ef23626f8831e5cb750ffca86e017e6dc"
  dependencies:
    broccoli-funnel "^2.0.1"
    ember-cli-babel "^6.10.0"
    ember-cli-htmlbars-inline-precompile "^1.0.0"

Turns out my knowledge of yarn is a little lacking. The fix I did was to remove my yarn lock file and do a fresh yarn install but after googling I think yarn upgrade would have done it too.

Now in my lock file I have the latest test helpers and tests are passing (without my terrible hacks :smile: )

"@ember/test-helpers@^0.7.18":
  version "0.7.25"
  resolved "https://registry.yarnpkg.com/@ember/test-helpers/-/test-helpers-0.7.25.tgz#b4014c108b40ffaf74f3c4d5918800917541541d"
  dependencies:
    broccoli-funnel "^2.0.1"
    ember-cli-babel "^6.12.0"
    ember-cli-htmlbars-inline-precompile "^1.0.0"

Frozenfire92 avatar Jul 30 '18 15:07 Frozenfire92

Yep, yarn doesn't really expose a way to force transient dependency updates other than yarn upgrade (or rm -rf yarn.lock && yarn) and resolutions (see here).

Also, I wasn't trying to suggest that ember-source itself depended on @ember/test-helpers. I meant that there is an issue when using older @ember/test-helpers along with [email protected] that we fixed in @ember/[email protected].

rwjblue avatar Jul 30 '18 15:07 rwjblue

oh ok, thanks for the clarification!

Frozenfire92 avatar Jul 30 '18 15:07 Frozenfire92

Just an FYI I've been stuck on this problem for the last few days until seeing your fix to remove and re-add ember-cli-qunit @rwjblue. I just used ember-cli-update to upgrade from 3.1 and the test helpers stopped working properly.

I don't know if there's an automatable solution but I can imagine a lot of others will have gotten stuck on this.

benkingcode avatar Aug 02 '18 18:08 benkingcode