Skip to content

Re-render does not occur synchronously when reactive data is changed in mounted life-cycle hook #1035

Closed
@Aaron-Pool

Description

@Aaron-Pool

Version

1.0.0-beta.25

Reproduction link

https://github.com/Aaron-Pool/vue-test-utils-jest-example

Steps to reproduce

  1. clone reproduction repo
  2. Run yarn
  3. run yarn jest

What is expected?

Test should pass, because reactive data changed in the mount component, so the scoped slot function should have been called again on re-render.

What is actually happening?

No re-render occurs, even though the data updates as expected.


I assume this has something to do with async vs. sync paradigm that is happening in the test-utils.

It works correctly if I run the test like so:

it('should initialize with dimension data', done => {
  const mockSlot = jest.fn();
  const comp = factory(mockSlot);
  comp.vm.$nextTick(() => {
    expect(mockSlot.mock.calls).toEqual([[{ width: null, height: null }], [{ width: 500, height: 500 }]]);
    done();
  })
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions