Git Product home page Git Product logo

cra-rbc's Introduction

CRA RBC Test

WEB

In this repository I am exploring how RBC-utilizing components could be tested using npm test in CRA.

RBC here refers to React Big Calendar. It's a shitty component, but writing your own is shitty, too, so there's that. It's also a complex component and in most applications I believe it will get wrapped in a nicer component with a more focused and smaller API surface, so I will specifically test a component which uses RBC internally. Not to mention you'd wanna do that to provide a better types for RBC, because its types, while constantly receiving more attention and improving, are not great and the underlying API design is not stellarly type-friendly either.

I read up on testing components in CRA.

From there I found that a good way is to use Enzyme and[] shallow rendering](https://facebook.github.io/create-react-app/docs/running-tests#option-1-shallow-rendering).

I put aside Jest matchers for reference.

I considered testing stateful components, but have decided to instance use the Enzyme accessors to test props of rendered VDOM tree of the component.

Enzyme allows simulating user interaction, so almost anything we would otherwise need state for can be tested that way. For example, a simple test of whether upon pressing an element, a modal appears, could consist of locating the button, thus ensuring it got rendered, then simulating a click on it, and then traversing the VDOM again looking for the modal container, ensuring that got rendered, too.

I am also using full DOM rendering when testing the calendar innards itself as it is a 3rd party library and I cannot test its components in isolation.

Debugging in the tests is supported and configured as per Debugging Jest tests

You can use the VS Code debugger with the Debug CRA tests configuration.

To-Do

Set up a GitHub Actions workflow for deploying GitHub Pages from docs

cra-rbc's People

Contributors

tomashubelbauer avatar

Watchers

 avatar  avatar  avatar

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.