- Notifications
You must be signed in to change notification settings - Fork 733
WIP: Add preact-testing-library documentation to testing-library.com/preact #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Thank you for adding documentation for Preact! I have a few comments, mostly related to the duplication of the existing React content and some differences that were missed in porting that over. I also think you can reference instead of copy some of the pages.
Don't forget to add the library to the homepage as well!
// jest.config.js | ||
module.exports = { | ||
setupFilesAfterEnv: [ | ||
'preact-testing-library/cleanup-after-each', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like this file exists in the library: https://github.com/antsmartian/preact-testing-library/blob/master/
| ||
## The problem | ||
| ||
You want to write maintainable tests for your Preact components. As a part of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This page could probably be a little more lightweight by referring to the home page and the React pages - this one is a little less likely to be updated promptly if it duplicates a lot of the content from another page
title: FAQ | ||
--- | ||
| ||
See also the [main FAQ](/docs/faq) for questions not specific to React testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should refer to the React FAQ if it doesn't have anything Preact-specific in it
// __tests__/fetch.js | ||
import preact from 'preact' | ||
import axiosMock from 'axios' | ||
import { cleanup, render, flushPromises, fireEvent } from '../' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be from 'preact-testing-library'
| ||
--- | ||
| ||
## `act` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not part of the Preact API
// your component has been unmounted and now: container.innerHTML === '' | ||
``` | ||
| ||
### `asFragment` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not seeing support for this option in https://github.com/antsmartian/preact-testing-library/blob/master/src/index.js
defaults to `document.documentElement`. This is used as the base element for the | ||
queries as well as what is printed when you use `debug()`. | ||
| ||
### `hydrate` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see this option in https://github.com/antsmartian/preact-testing-library/blob/master/src/index.js
| ||
```typescript | ||
function render( | ||
ui: React.ReactElement<any>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Preact have separate typings?
| ||
- [`render`](#act) | ||
- [`cleanup`](#cleanup) | ||
- [`act`](#act) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I see
debounceRenderingOff
andflushPromises
methods that are not mentioned here act
is not in the Preact implementation
| ||
const Logo = props => ( | ||
<div className="projectLogo"> | ||
<img src={props.img_src} alt="Project Logo" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this point to a SVG of the Preact logo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any news on getting preact-testing-library over here? |
Haven't had time to continue this yet. |
This commit was already completed in #273 , the docs are now available. |
Basically, I copied react-testing-library docs and replaced some of it with content from https://github.com/antsmartian/preact-testing-library
Related to testing-library/preact-testing-library#11
Needs a review, updates, and probably a consideration if all of this is even needed.