question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Testing Fresh Components

See original GitHub issue

Issue: 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:open
  • Created a year ago
  • Reactions:12
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
sigmaSdcommented, Sep 20, 2022

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)

3reactions
audrowcommented, Jul 13, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Concrete Testing Procedures - Tests for Slump & More
Fresh concrete tests run along with a set of compressive strength cylinders are: slump, air content, unit weight and temperature. Data from these...
Read more >
Why Complete Testing of Fresh Concrete Matters
This post will focus on the importance of complete fresh concrete testing, including concrete air content, the role these tests play in guaranteeing...
Read more >
Test your elements - Polymer Project
Web Component Tester is an end-to-end testing environment built by the Polymer team. It enables you to test your elements locally, against all...
Read more >
Microbiological Testing of Fresh Produce
It is one component of an overall food safety system. Before microbiological testing is initiated, prerequisite programs must be in place. These should...
Read more >
Introduction to Specimen Collection | Labcorp
Laboratory tests contribute vital information about a patient's health. ... Avoid hemolysis: red blood cells broken down and components spilled into serum.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found