Skip to content
This repository has been archived by the owner. It is now read-only.

Standard rendering as a catch-all test, thoughts? #561

Closed
mcrowder65 opened this issue Jan 29, 2019 · 2 comments
Closed

Standard rendering as a catch-all test, thoughts? #561

mcrowder65 opened this issue Jan 29, 2019 · 2 comments

Comments

@mcrowder65
Copy link

@mcrowder65 mcrowder65 commented Jan 29, 2019

Hey Kent! 馃憢

Just another javascript developer who migrated their entire test suite to react-testing-library from enzyme, and we love it so far.

Just wondering your thoughts on something:

A pattern that I have decided to do is always just render a component without even checking for anything, just to ensure that it renders, this mainly catches things like if file imports broke or if perhaps you're not checking for an undefined variable.

Example:

import React from "react";
import MyComponent from "../my-component";
import { cleanup } from "react-testing-library";
// this is just a wrapped render our react-testing-library render that wraps all of our providers - React intl, material-ui, redux, apollo, etc.
import { render } from "client/../../test/test-utils";

afterEach(cleanup);

test("that it renders without issues", () => {
    render(<MyComponent/>);
});

And this will just be the first line of defense to ensure that we have something that's checking something on the component.

Just wondering what your thoughts are and if this something dumb or not?

Thanks!!!

@kentcdodds
Copy link
Owner

@kentcdodds kentcdodds commented Jan 29, 2019

Hi @mcrowder65!

This is a great question! Here's my answer: https://www.briefs.fm/3-minutes-with-kent/81

@kentcdodds kentcdodds closed this Jan 29, 2019
@mcrowder65
Copy link
Author

@mcrowder65 mcrowder65 commented Jan 29, 2019

Thank you Kent! Very useful, +1 to testingjavascript.com, I really enjoyed the react-testing-library section, still need to make my way through the cypress one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants