Skip to content

How to test two way data-binding? #117

Closed
testing-library/testing-library-docs
#1366
@yjp20

Description

@yjp20

As far as I can tell, just passing in a variable into the render function doesn't enable two way data binding. Despite being an anti-pattern, two-way data binding is actually useful in a lot of cases, so it would be nice if there was a way to ensure that it works.

Edit:
I suppose you could also do something like

const utils = render(Input, { value: "" });
const component = utils.component.$$;
/*
* Update component such that value = asdf
*/
expect(component.ctx[component.props["value"]]).toBe("asdf")

But it's a bit repetitive and there's probably at least some justification in putting in a helper function into the library (since the framework supports it after all)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions