Skip to content

Conversation

olpeh
Copy link

@olpeh olpeh commented Feb 21, 2019

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.

Copy link
Collaborator

@alexkrolick alexkrolick left a 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',
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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 '../'
Copy link
Collaborator

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`
Copy link
Collaborator

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`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


```typescript
function render(
ui: React.ReactElement<any>,
Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I see debounceRenderingOff and flushPromises 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" />
Copy link
Collaborator

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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also add the library to the main homepage listings:

screen shot 2019-02-25 at 6 10 39 pm

@alexkrolick alexkrolick added the 🚧 work in progress Not ready, being worked on label Mar 18, 2019
@fondberg
Copy link

Any news on getting preact-testing-library over here?

@olpeh
Copy link
Author

olpeh commented Aug 21, 2019

Haven't had time to continue this yet.

@mihar-22
Copy link
Contributor

mihar-22 commented Oct 8, 2019

This commit was already completed in #273 , the docs are now available.

@mihar-22 mihar-22 closed this Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚧 work in progress Not ready, being worked on

4 participants