Open seanmturley opened 9 months ago
Having trouble setting up testing for Post
.
Jest
is throwing an error:
Unexpected token: 'export'
The error appears to originate in the ReactMarkdown
pacakge.
After trying a few other solutions involving modifying the Jest
config, the top answer on this Stack Overflow question is what worked.
The Post
test suite now appears to be running, though I won't be completely sure until there's actually a valid and passing test (the test setup isn't complete yet).
I haven't had much luck setting up the Post
tests.
I can't get the component to render - Jest
claims it's not wrapped in a Provider
, though it should be (a similar setup has worked with various other components). It's possible the problem here is that unlike previous tests I've set up using my setupWithRouting
utility function, Post
requires accessing Reddit API data via React Router
's loader
.
I suspect this is going to take a fair bit of work to untangle, and at this point my priority is to get the project into a presentable state, so I'm going to leave this as it is for now.
Making a note here that in addition to the complexity of modal vs fullpage presentations of Post
, there's also the possibility of viewing a specific comment and its replies by adding the optional commentId?
parameter (fullpage view only). Ideally, this should also be tested.
Description
Add tests for the Post component.
A guide to testing React Router related functions is available in the official Testing Library documentation.
Tests:
Note that a lot of the specifics in
Post
are already adequately tested inCard
tests (i.e. formatting of post age and upvotes/score). There's no need to repeat these detailed tests here, instead just general tests should be added to check e.g. post age is rendered.Post should display:
Test modal vs full page views