We want to ship client side behavioural elements with Primer View Components to increase the fidelity of our components.
Doing so requires us to align to a set of constraints for the Browser ecosystem, as well as the ecosystems that consumers of Primer View Components have:
The artefact should be easily consumable by existing tool chains of our consumers, which may or may not be the Rails Asset Pipeline.
Client side behaviours should be well tested and offer the same level of quality the existing non-behavioural components do.
Publishing to npm
We will test our behaviours in the Browser environment (using Rails System tests), as this is where they will be consumed. This will require using Browser APIs to automate testing. We will use test automation libraries that automate browsers via the Devtools Protocol such as Puppeteer, Playwright or Ferrum. Using a Devtools Protocol based tool gives us the best level of flexibility in testing, while also being compatible with current browsers.
This library will be able to provide behaviours for higher fidelity components, using consistent methods that lean to the strengths of the Rails & JS ecosystems.
Contributors of Primer View Components will need to have an understanding of TypeScript if they wish to author behavioural components.