react-native-webview.git

testWebView.spec.js 970B

12345678910111213141516171819202122232425262728293031323334
  1. import {Platform} from 'react-native';
  2. describe('WebView basic test', () => {
  3. beforeEach(async () => {
  4. await device.launchApp({newInstance: true});
  5. });
  6. it('should not have a redbox visible', async () => {
  7. const platform = Platform.select({
  8. ios: 'RCTRedBoxWindow',
  9. android: undefined, // TODO -- need to figure out what RedBox is on Android
  10. });
  11. if (platform) {
  12. expect(element(by.type(platform))).toNotExist();
  13. }
  14. // so there's at least one assertion
  15. expect(true).toBe(true);
  16. });
  17. it('should have a webview', async () => {
  18. await expect(element(by.id('test_webview'))).toBeVisible();
  19. });
  20. it('should respond to injectJavaScript', async () => {
  21. const hello = await element(by.id('hello'));
  22. await expect(hello).toHaveText('No hello yet');
  23. await element(by.id('test_trigger_button')).tap();
  24. await waitFor(hello)
  25. .toHaveText('Hello from the webview!')
  26. .withTimeout(10000);
  27. });
  28. });