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

Inconsistent behaviour with async tests #251

Open
njoyard opened this issue Feb 8, 2019 · 0 comments
Open

Inconsistent behaviour with async tests #251

njoyard opened this issue Feb 8, 2019 · 0 comments

Comments

@njoyard
Copy link

njoyard commented Feb 8, 2019

Test scenario:

  • Register the ember-raf-scheduler waiter in tests/test-helper.js
  • Use the following test:
  test('vertical-collection async test', async function(assert) {
    let items = A()

    function loadMore() {
      items.pushObjects([...Array(10).keys()].map(() => Math.random()))
    }

    loadMore()
    this.setProperties({
      items,
      lastReached() {
        loadMore()
      }
    })

    await render(hbs`
      <div class="vertical-collection">
        {{#vertical-collection
          items
          estimateHeight='100px'
          containerSelector='#ember-testing-container'
          renderAll=true
          lastReached=lastReached
          as |item|}}
          <div style="height: 100px;" class="item">{{item}}</div>
        {{/vertical-collection}}
      </div>
    `)

    assert.dom('.item').exists({ count: 10 })

    document.querySelector('.vertical-collection').scrollIntoView(false)
    await settled()

    assert.dom('.item').exists({ count: 20 })
  })

Running this test repeatedly fails randomly on the second assert (only 10 items present). As I understand it, registering the waiter should be enough that awaiting for settled() (or other ember async helpers) ensures that vertical-collection updates are finished. But maybe I am wrong?

May be related to #231 ?

@njoyard njoyard closed this as completed Feb 8, 2019
@njoyard njoyard reopened this Feb 8, 2019
@njoyard njoyard changed the title Inconsistent behaviour with async in tests Inconsistent behaviour with async tests Feb 8, 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

1 participant