Commit Graph

27 Commits

Author SHA1 Message Date
Jukkish c3672cf23e feat: compile to ES5 for publishing (#50)
### Summary

Fixes https://github.com/callstack/react-native-testing-library/issues/49
2018-11-23 10:07:42 +01:00
Michał Pierzchała e407ff07ae feat: deprecate getByName helpers (#66) 2018-11-19 15:16:33 +01:00
Michał Pierzchała 909916e84c feat: add debug to render helpers for easier console debugging (#65)
* feat: add debug to render helpers for easier console debugging

* bring back toJSON to docs

* revert unnecessary change

* update TS

* remove cyclic dependency of debug <-> render
2018-11-19 13:51:38 +01:00
Michał Pierzchała fa198c4037 feat: add getByType helper (#64)
* feat: add getByType helper

* add docs
2018-11-19 13:44:51 +01:00
Michał Pierzchała 235942bee3 fix(breaking): correct faulty implementation of finding by name (#62)
* fix(breaking): correct faulty implementation of finding by name

* chore: update docs

* refactor: code review
2018-11-17 19:13:44 +01:00
Michał Pierzchała 01249f6609 Revert "fix: getAllBy* methods return more elements than expected (#57)" (#60)
This reverts commit d6d225d825.
2018-11-14 14:07:43 +01:00
Michał Pierzchała d6d225d825 fix: getAllBy* methods return more elements than expected (#57)
<!-- Please provide enough information so that others can review your pull request. -->
<!-- Keep pull requests small and focused on a single change. -->

### Summary

While upgrading the RN dev dep to 0.57.5 our test suite caught a bug, where `getAllBy*` methods would return more elements than expected. This is fixed by making sure we check the proper type of the parameter when we compare it directly to `node.type` (should be a function, but we allowed strings)

### Test plan

Updated snapshot (yay! RN fixed the display names of View and Text)
2018-11-13 19:26:47 +01:00
Michał Pierzchała 6fbbe2cdf5 feat: make debug.deep more usable (#40)
<!-- Please provide enough information so that others can review your pull request. -->
<!-- Keep pull requests small and focused on a single change. -->

### Summary

Make `debug.deep` more usable by allowing it to print arbitrary JSON (and actually any) files. This proves handy when we want to debug async component which we want to snapshot after async operations:

```jsx
const { toJSON, getByName } = render(
  <Button onPress={jest.fn} text="Press me" />
);
fireEvent.press(getByName('TouchableOpacity'));
await flushMicrotasksQueue();

debug.deep(toJSON());
```

### Test plan

added one
2018-10-18 09:13:47 +02:00
Michał Pierzchała 05db7bcaac feat: add debug.deep and debug.shallow (#37)
<!-- Please provide enough information so that others can review your pull request. -->
<!-- Keep pull requests small and focused on a single change. -->

### Summary

Adds API proposed by https://github.com/callstack/react-native-testing-library/pull/33#issuecomment-430302079.
Also component output is now highlighted:

<img width="259" alt="screenshot 2018-10-16 at 19 33 25" src="https://user-images.githubusercontent.com/5106466/47035614-c10efb80-d17a-11e8-99ac-00f648880008.png">


### Test plan

Added tests for `debug`.
2018-10-16 21:45:56 +02:00
Michał Pierzchała 03e2c4b0f2 fix: use actual react-native instead of homegrown mocks (#36)
<!-- Please provide enough information so that others can review your pull request. -->
<!-- Keep pull requests small and focused on a single change. -->

### Summary

This actually uncovered some bugs, like lack of `onDoublePress` (lol XD) and enabled us to have better snapshots for deep rendering.

### Test plan

no new tests
2018-10-16 18:51:01 +02:00
Michał Pierzchała 07d3be1c51 feat: add toJSON to render; cleanup shallow (#35)
* feat: add toJSON to render; cleanup shallow

* Remove empty dependencies entry

* revert shallow import

* add docs

* add TS typings
2018-10-16 18:00:54 +02:00
Kacper Wiszczuk a066544019 fix: Remove unnecessary flow expression (#31) 2018-10-15 20:57:13 +02:00
Kacper Wiszczuk a39f879288 fix: do not bubble event to root element (#30)
Remove bubbling events to the root element as in the most common use case we pass handler prop to the root element:
```jsx
// That's usually what we do in tests
const tree = render(<SomeElement onPress={mockedHandler} />);

// Unsupported use case
const tree = render(<TouchableOpacity onPress={mockHandler()}><Text>XD</Text></TouchableOpacity>)
```
2018-10-15 17:03:30 +02:00
Kacper Wiszczuk 480dd28cbc feat: Add Typescript types to waitForElement (#21)
Fix types for Flow too
2018-10-10 21:45:32 +02:00
Michał Pierzchała d5219d2e93 feat: add waitForElement (#20)
* feat: add waitForElement

* add docs

* update docs
2018-10-10 21:06:06 +02:00
Michał Pierzchała 254127781c test: add tests for shallow rendering (#19) 2018-10-10 17:38:20 +02:00
Michał Pierzchała 2f002014cf fix: stack traces for get APIs (#17)
<!-- Please provide enough information so that others can review your pull request. -->
<!-- Keep pull requests small and focused on a single change. -->

### Summary

When moving `get` APIs outside of `render`, we needed to wrap them with a closure injecting `instance` to act on. This resulted in an anonymous callsite that wasn't properly processed by our `ErrorWithStack` helper.



### Test plan

|before|after|
|--|--|
|<img width="305" alt="screenshot 2018-10-07 at 16 09 27" src="https://user-images.githubusercontent.com/5106466/46582694-6fb08f00-ca4b-11e8-94f8-40dcb2211d46.png">|<img width="491" alt="screenshot 2018-10-07 at 16 09 18" src="https://user-images.githubusercontent.com/5106466/46582698-73dcac80-ca4b-11e8-94ce-4fd16ce1f845.png">|
2018-10-07 17:10:26 +02:00
Kacper Wiszczuk 4f0501e6b5 fix: Flow types (#16)
- [x] - Add flow to tests
- [x] - Fix flow typings
- [x] - Update documentation
2018-10-07 14:50:05 +02:00
Michał Pierzchała 495811bd08 feat: add query API (#13)
* feat: add query API

* use plural for API

* return empty array from queryAll

* fix wording in readme

* move mass exports to get/query files
2018-10-07 10:59:27 +02:00
Kacper Wiszczuk d66255d482 feat: fireEvent API (#11)
Implementation of fireEvent API.

Fixes #7
2018-10-07 08:23:21 +02:00
Michał Pierzchała 9d14406832 BREAKING: make getAllBy* methods throwable (#12)
* BREAKING: make getAllBy* methods throwable

* fix wrong fn args
2018-10-06 23:42:52 +02:00
Michał Pierzchała f7f2103062 feat: improve stack traces for throwable methods 2018-10-05 00:07:55 +02:00
Michał Pierzchała e74e928b4f Add basic tests for render (#8) 2018-10-04 23:41:46 +02:00
Michał Pierzchała e6ac5ad997 pass options to renderer; add update & unmount, rm instance & renderer 2018-10-03 20:21:20 +02:00
Michał Pierzchała 520355a645 change shallow output to be more future proof 2018-10-03 19:27:32 +02:00
Michał Pierzchała c4a0dd7763 update readme 2018-10-03 19:15:36 +02:00
Michał Pierzchała ac77a55068 inital commit 2018-10-01 18:15:56 +02:00