Giter VIP home page Giter VIP logo

Comments (8)

abenhamdine avatar abenhamdine commented on June 2, 2024

Hi @edorivai you can check the third item now

from react-media.

0ctothorp avatar 0ctothorp commented on June 2, 2024

Hey, I could work on tests for the hook. Is there anything specific that I should know of before starting?

from react-media.

tstirrat15 avatar tstirrat15 commented on June 2, 2024

@0ctothorp let me push a branch that I've been working on. Transliterating the existing tests shouldn't be difficult, but the thing that I was finding hard is that testing the SSR behavior.

from react-media.

0ctothorp avatar 0ctothorp commented on June 2, 2024

Oh, I didn't know it was being worked on already 😅

from react-media.

tstirrat15 avatar tstirrat15 commented on June 2, 2024

I've stalled out :P I would very much appreciate the help if you're willing and able.

The big thing is that for testing SSR behavior, you want to watch three states and make sure that they're all consistent with each other:

  1. the server-rendered markup
  2. the first hydration pass
  3. the first full render pass

In a two-pass render, you want the first two to agree, and then for the change to happen between the second and third. I'm having trouble testing this, though, because the React Testing Library doesn't really account for a desire to see the middle state and be able to compare it to the first and third states. I was working on a workaround of some sort for that when I stalled out.

from react-media.

tstirrat15 avatar tstirrat15 commented on June 2, 2024

Here's a link to the branch I've been working on:

https://github.com/tstirrat15/react-media/tree/155-testing-and-implementing-two-pass-render

And here's a link to the diff between it and current master:

https://github.com/ReactTraining/react-media/compare/master...tstirrat15:155-testing-and-implementing-two-pass-render?expand=1

It's very much a work in progress - I started writing the hydration tests by copying and pasting a bunch of existing tests, then went and started trying to solve my problem above, and I didn't get much further than that.

Tests are "passing," but that's because they're not actually capturing the desired behavior.

from react-media.

0ctothorp avatar 0ctothorp commented on June 2, 2024

Cool, I'm going to have a look. I'm definitely not an expert in such tests, but maybe I will be able to come up with something :)

from react-media.

tstirrat15 avatar tstirrat15 commented on June 2, 2024

Awesome. Thank you so much!

from react-media.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.