Testing Fresh Components
See original GitHub issueIssue: Deno testing suit documentation does not elaborate on how to render and test components.
Discussion: I have been having trouble finding ways to conduct unit tests for Fresh components. When using react-testing-library, we can use render(<MyComponent newProp={'myProp') />)
to render the component and test. However, this feature is missing with the current testing suit on Deno.
To “hack” a solution together I had tried using dom-testing-library and I had tried using preact render, however neither of these solutions allowed me to test if the component is working the way I expect it to. I had also tried importing react-testing-libaray as a “hail Mary”.
I understand Cypress is looking into how to perform integrated tests on Deno right now, however, finding a way to implement unit tests in fresh will allow us to improve TDD within this framework.
Recommendation: Documentation should be upgraded which describes how to render a component for testing. I do not think we need a new API or a new library to accomplish said means. That said, I do not have a solution for this problem yet.
Issue Analytics
- State:
- Created a year ago
- Reactions:12
- Comments:13 (1 by maintainers)
Top GitHub Comments
for jsdom I imported it with npm:jsdom and I had to patch
vm.isContext
to return false (https://github.com/denoland/deno_std/issues/2667)I haven’t yet tried this, but maybe the answer is to use the testing that comes with Preact. https://preactjs.com/guide/v10/preact-testing-library