Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Passing arguments into components while testing. #14
Is it possible to pass arguments into components while rendering them for testing?
I understand that this is a contrived example as I could just pass "10" directly, but I would also like to be able to pass closure actions (not in current documentation, I found an example here).
There is not a super easy API for doing this yet, although it's being worked on and is high priority once all of the recent performance-related work stabilizes.
If you have the appetite for hacking on low-level VM APIs, there is theoretically a way to do this today.
The core Glimmer "initial render loop" happens when you create a template iterator and call
The template iterator encapsulates a few different pieces of state required to perform the render.
So if there's no component, how does the template get data? If I type
Specifically for the root template, that comes from a special
In Glimmer.js apps,
If we combine these concepts, it should be possible to build a test helper that:
I wanted to write down how this stuff works in case someone is highly motivated to dig in themselves, but I'll be upfront that it's a non-trivial amount of work involving low-level parts of the VM. It might be a fun project, but if you're just wanting to get work done, the best answer might be to wait for the
pushed a commit
Oct 27, 2017
Small update here:
The update in the PR I linked unregistered the main ComponentManager which we needed. glimmerjs/glimmer-test-helpers#5 Fixes that. I've confirmed in my own project that on