Skip to content

Commit

Permalink
chore: Check if testing API is compatible with React Native (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidiuch committed Jul 10, 2018
1 parent 3e97c86 commit 4958e44
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -27,7 +27,7 @@
</a>
</p>

> **New: [Try out Cosmos with React Native!](#experimental-react-native)**
> **New: [Try out Cosmos with React Native!](#beta-react-native)**
Cosmos scans your project for components and enables you to:

Expand Down Expand Up @@ -98,7 +98,7 @@ Jump to:
- [Updating fixtures in tests](#updating-fixtures-in-tests)
- [createTestContext API](#createtestcontext-api)
- [Global Jest snapshot](#global-jest-snapshot)
- [Experimental: React Native](#experimental-react-native)
- [Beta: React Native](#beta-react-native)
- [Experimental: Flow integration](#experimental-flow-integration)

_Have a question or idea to share? See you on [Slack](https://join-react-cosmos.now.sh/)._
Expand Down Expand Up @@ -1205,7 +1205,7 @@ runTests({
});
```

### Experimental: React Native
### Beta: React Native

> Install `react-cosmos@next` to try out Cosmos with React Native
Expand Down
4 changes: 2 additions & 2 deletions TODO.md
Expand Up @@ -31,11 +31,11 @@
- [x] Create RN-specific onboarding screens
- [ ] Test socket transport
- [ ] Log using `debug` on the client
- [ ] RN loader
- [x] RN loader
- [x] Extract non ReactDOM-specific core from react-cosmos-loader
- [x] Create RN loader
- [x] Test socket transport
- [ ] Check if existing proxies are compatible
- [ ] Check if testing API is compatible
- [x] Check if testing API is compatible
- [x] Create React Native App example
- [x] Add (experimental) README section
23 changes: 23 additions & 0 deletions examples/create-react-native-app/StatefulCounter/index.test.js
@@ -0,0 +1,23 @@
import { Button } from 'react-native';
import { create as renderer } from 'react-test-renderer';
import createContext from 'react-cosmos-test/generic';
import fixture from './index.fixture';

const { mount, getWrapper } = createContext({ renderer, fixture });

beforeEach(mount);

it('displays mocked count', async () => {
expect(getButtonProps().title).toBe('Clicked 5 times');
});

it('displays incremented count', async () => {
const { onPress } = getButtonProps();
onPress();
onPress();
expect(getButtonProps().title).toBe('Clicked 7 times');
});

function getButtonProps() {
return getWrapper().root.findByType(Button).props;
}
1 change: 1 addition & 0 deletions examples/create-react-native-app/package.json
Expand Up @@ -14,6 +14,7 @@
"expo": "^28.0.0",
"react-cosmos": "^4.6.0-2",
"react-cosmos-loader": "^4.6.0-2",
"react-cosmos-test": "^4.6.0-2",
"react-native": "^0.55.4"
},
"devDependencies": {
Expand Down

0 comments on commit 4958e44

Please sign in to comment.