Git Product home page Git Product logo

formidablelabs / react-native-owl Goto Github PK

View Code? Open in Web Editor NEW
615.0 41.0 26.0 31.99 MB

Visual regression testing library for React Native that enables developers to introduce visual regression tests to their apps.

Home Page: https://formidable.com/open-source/react-native-owl/

License: MIT License

JavaScript 3.01% TypeScript 72.53% Java 5.88% Objective-C 1.23% Ruby 1.27% CSS 2.64% HTML 12.84% Objective-C++ 0.61%
react-native react visual-regression ios android javscript typescript

react-native-owl's Introduction

React Native Owl

react-native-owl β€” Visual regression testing for React Native

Sample of using React Native Owl to generate a visual regression diff


github npm docs Maintenance Status

What is React Native Owl?

React Native Owl is a visual regression testing library for React Native that enables developers to introduce visual regression tests to their apps for iOS and Android. Being heavily inspired by Detox, an end-to-end testing and automation framework, this library uses a similar API that makes setting up react-native-owl and running the tests locally and on your preferred CI service seamless.

While Detox focuses on end-to-end testing in general, React Native Owl focuses on visual regression testing and helping you catch unexpected changes to the visual appearance of your app over time.

Installation

yarn add -D react-native-owl
# or
npm install -D react-native-owl

πŸ“ƒ Documentation

The documentation contains everything you need to know about react-native-owl, and contains several sections in order of importance when you first get started:

  • Getting started β€” contains the "Getting Started" guide.
  • Configuration β€” explains all the configuration options for react-native-owl.
  • Running on CI β€” example GitHub Action to run react-native-owl on CI.

You can find the raw markdown files inside this repository's docs folder.

Contributing

Please see our contributing guide.

Maintenance Status

Active: Formidable is actively working on this project, and we expect to continue work on this project for the foreseeable future. Bug reports, feature requests and pull requests are welcome.

react-native-owl's People

Contributors

carbonrobot avatar ceceppa avatar cpresler avatar fel1xw avatar gabimoncha avatar github-actions[bot] avatar gksander avatar ipagar avatar jayzes avatar jdmathew avatar leotm avatar manosim avatar markrickert avatar narinluangrath avatar paperbagwriter avatar paulmarsicloud avatar retyui avatar robwalkerco avatar ryan-roemer avatar zibs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-owl's Issues

Issue with the methods import

The only method that I am able to use is takeScreenshot.

Screenshot 2022-05-23 at 16 30 30

I can see inside the lib/actions.ts all the listed methods which seem not correctly exported.

State always has initial value when submitting in tests

I'm testing out react-native-owl and it's great library!
I encountered one strange issue - in my test app I have search input with submit button. Search query is saved in state (with useState). When I press "Search" button, it requests backend and shows results. When I test it with react-native-owl, the query is always empty. I added <Text> with text value and it displays valid value, but when I press submit button and it's empty.
I tried to reproduce it using your demo app https://github.com/FormidableLabs/react-native-owl-demo so I added submit button with onPress={() => Alert.alert('text from state', text)} and it's also empty. When I pressed it manually afterwards (during test) it shows valid text.

Tested on iOS simulator and Android emulator.

https://github.com/marcinkornek/react-native-owl-demo-test link to react-native-owl-demo with changes mentioned below.

image

image

Please see videos below:

  • when testing it manually in simulator
Screen.Recording.2022-11-08.at.09.23.35.mov
  • when running react-native-owl tests
Screen.Recording.2022-11-08.at.09.28.11.mov

Docs sites: various things

When native alerts such as permission requests are shown there is no way to get past them

If an app shows a native alert such as the iOS transparency tracking alert or a request for permission to access part of the os such as images or contracts, there doesn't seem to be a way to get past that screen using the react-native-owl api. Other testing systems generally have a way to auto accept all requests or auto deny all requests or handle them on a prompt by prompt basis. This would stop our team from implementing the testing library

[Android] Running tests on Github Action

We are building our app with JDK 11

      - name: Set up JDK 11
        uses: actions/setup-java@v1
        with:
          java-version: '11'

However when trying to run commands like avdmanager, we are getting the following error:

$ANDROID_HOME/tools/bin/avdmanager create avd -n Pixel_API_30 --device 'Nexus 5X' --package "system-images;android-30;default;x86_64" --sdcard 512M
Error: Exception in thread "main" java.lang.NoClassDefFoundError: **javax/xml/bind/annotation/XmlSchema**

We're not sure how to fix the error; I'm also getting the same error if I try to run the same command on my laptop.

Error running on Bitrise CI

Hello,

Thank you for the library! I tried it, initially looks good but I've got a problem running it on CI.
Getting error: Error: Command failed with exit code 149: xcrun simctl status_bar iPhone 11 override --time 9:41

Seems like it isn't possible to run in headless mode?
(we already have successfully running detox tests, but looking into visual regression tests)

react-native-owl not working on Android

Tried setting up React-Native-Owl on React-Native Project to capture screenshots on Android. It doesn't work!

Setup

  • Setup owl.config.json as per the documentation.
{
    "android": {
      "packageName": "com.loki",
      "quiet": true
    },
    "debug": true,
    "report": true
  }
  • npm run owl build -- --platform android - Works fine βœ…
  • npm run owl test -- --platform android - Fails ❌

Error

> [email protected] owl /Users/nikhilmittal/Desktop/Github/loki
> ./node_modules/react-native-owl/dist/cli/index.js "test" "--platform" "android"

[OWL] Starting websocket server.
[OWL] Running tests on android.
[OWL] WebSocket now listening on port 8123.
Sat Jan  1 09:41:00 IST 2022
date: cannot set date: Operation not permitted
Error: Command failed with exit code 1: adb shell date 01010941
    at makeError (/Users/nikhilmittal/Desktop/Github/loki/node_modules/react-native-owl/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/Users/nikhilmittal/Desktop/Github/loki/node_modules/react-native-owl/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  shortMessage: 'Command failed with exit code 1: adb shell date 01010941',
  command: 'adb shell date 01010941',
  escapedCommand: 'adb shell date 01010941',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

Timeout - Async callback was not invoked within the 30000 ms timeout

When running the test, I receive this error specified by jest.setTimeout.Timeout - Async callback was not invoked within the 30000 ms timeout specified by jest.setTimeout.Error:

The first one works.

  it('takes a screenshot of the initial screen', async () => {
    const screen = await takeScreenshot('initial');

    expect(screen).toMatchBaseline();
  });

The second one doesn't work.

 it('show loading, then takes a screenshot', async () => {
    await press('showLoading'); // if I remove this line, it is working.
    const screen = await takeScreenshot('show-loading');
    expect(screen).toMatchBaseline();
  });

My opinion is that when calling the press function, it doesn't find the testID.
My code:

 return (
    <SafeAreaView style={backgroundStyle}>
      <StatusBar
        barStyle={isDarkMode ? 'light-content' : 'dark-content'}
        backgroundColor={backgroundStyle.backgroundColor}
      />
      {loading && <ActivityIndicator />}
      <Pressable testID="showLoading" onPress={() => setLoading(true)}>
        <Text>Show Loading</Text>
      </Pressable>
    </SafeAreaView>
  );

My repo link is here: https://github.com/burhanyilmaz/reactNativeOwl
my logs exist on there.

[iOS] Running tests on Github Action

Congratulations on this awesome project πŸΎπŸŽ‰

We are considering using it for RN Skia, and we are running into a small issue with having the xcrun command available on Github action. This is how the workflow looks like:

jobs:
  build:
    runs-on: macos-12
    concurrency:
      group: ios-example-${{ github.ref }}
      cancel-in-progress: true
    steps:
      - name: Get Runner Information
        run: /usr/bin/xcodebuild -version # returns Xcode 14.0.1
# build app...
      - uses: futureware-tech/simulator-action@v1
        with:
          model: 'iPhone 14 Pro'
          os_version: '>=16.0'

      - name: e2e Tests
        working-directory: example
        run: yarn e2e:test:ios

Returns the following error:

$ owl test -p ios
[OWL - CLI] Starting websocket server.
[OWL - CLI] Running tests on ios.
Error: Command failed with ENOENT: xcrun simctl status_bar booted override --time 9:41
spawn xcrun ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16))
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn xcrun',
  path: 'xcrun',
  spawnargs: [ 'simctl', 'status_bar', 'booted', 'override', '--time', '9:41' ],
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  originalMessage: 'spawn xcrun ENOENT',
  shortMessage: 'Command failed with ENOENT: xcrun simctl status_bar booted override --time 9:41\n' +
    'spawn xcrun ENOENT',
  command: 'xcrun simctl status_bar booted override --time 9:41',
  escapedCommand: 'xcrun simctl status_bar booted override --time "9:41"',
  exitCode: undefined,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

Do you have any leads on how we could investigate this issue further? Do you plan yourself to run such commands on your own CI?

[iOS] tests don't run in debug mode

When building the app in debug mode, the app launches nicely when running the test but then nothing happens and jest will eventually timeout:

 Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.

is this expected?

Yarn workspace support

Hi,

I'm very excited to try out this library.
Unfortunately, my app is in a yarn workspace.
Is there a way to configure where it is looking for the owl library?

I'm getting this error when I try to run owl build.

The resource `.../native-app/node_modules/react-native-owl/dist/client/index.app.js` was not found

The build script seems to be looking in the package for node_modules, but the node_modules are at the root of project because they were hoisted via yarn workspaces.

Improve report ordering, status labels etc...

The report should be ordered according to the time the screenshot was taken.

The report should have a passed/failed label on each screenshot.

When a screenshot matches, we don't need to store the screenshot or the diff. We can just use the base image. This will speed up the tests

[Expo] All commands that deal with testID elements do not work

Hey-hey

Thanks for such a promising tool. Installation & setup was pretty easy.
Taking & comparing screenshots work flawlessly, but any action that needs element(press, longPress, changeText, toExist) matching throws error Failed: "Element not found: ZZZZZZZ".

Relevant for both iOS & Android, release build(can't try debug as i'm using Expo custom dev client).
What could be the problem and how to debug it?

Expo support?

It's clear from the docs that this works if you build your own app. But what if you really wanna stay in the Expo eco system?

Is there an EAS plugin solution that makes it possible to make EAS build it with a custom dev client?

Screenshot is only for initial screen

ATM the screenshot can be taken only for the home screen. Ignoring the fact that some apps might stay longer in splash screen because of increasing startup time, there is no way of waiting for screens based on testID as in Detox or triggering any kind of actions.

Discord channel?

Hi,
Do you have a Discord channel or any forms of less async communication?
I'm having some build issues that are mostly related to the cli implementation. I've had to add an additional config prop name because the app's name is different then the scheme, print error logs because they weren't showing in the terminal and I still get the Print: Entry, ":CFBundleIdentifier", Does Not Exist error when trying to test.

[Android] Issue with Immersive mode image failing tests

Hello πŸ‘‹

When running the visual regression tests for Android locally and on the pipeline the app loads into immersive mode and shows the following message.
This is fine locally as I can just click on Got it and it won't show on any subsequent test runs but on the pipeline this isn't possible.
immersivemode

We have found a way of dismissing this message locally by running this adb command before taking the screenshot
exec('adb shell input text "mock\\ text"');
But when trying this on the pipeline, the latest screenshot shows the navigational buttons and top status bar as so.
Screenshot 2022-11-01 at 09 48 00

Is there a more effective way of dismissing that Android message?

Docs: deployment

After talking with @formidableamy I think here's our goal:

We'll plan to use https://github.com/FormidableLabs/formideploy which out-of-the box gives us per-PR deploys with deployment notifications and links in PR and takes care of the production deploy. ( Note: deploys of this project will be completely independent of formidable.com deploys or any other project )

Work to get there:

  • Reconfigure docusaurus to build to /open-source/react-native-owl/ instead of /. (I'm assuming docusaurus can easily do this).
  • Hook up formideploy to CI, replace placeholder deploy stuff, etc.
  • Add formidops user, GH CI user, and add secrets to this repo.
  • Make necessary changes in formidable.com website to accommodate the new site.
  • Clean up the website Docusaurus template docs (e.g. shouldn't mention deploy because we do it our way)

I'll try to get started on this this week so we have a staging site to look at by Monday.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.