expo / config-plugins

Out-of-tree Expo config plugins for packages that haven't adopted the config plugin system yet.
445 stars 95 forks source link

Using detox plugin #34

Closed Norfeldt closed 2 years ago

Norfeldt commented 2 years ago

The readme seems really well written however I do face some issue that I hope you can help me we details on.

'yarn e2e:ios'

I don't have this script in my package.json made the project by expo init. What do you suggest me to do?

jetaix commented 2 years ago

@Norfeldt I think this should be useful to you

"scripts": {
    "e2e:ios": "npm run build:ios && npm run test:ios"
}

source: package.json

Norfeldt commented 2 years ago

Oh, I thought I could use the plugin in a managed app with the expo go client.

I use a macBook but really enjoy not having to compile locally (or do anything in xcode)

EvanBacon commented 2 years ago

@Norfeldt sorry for the misunderstanding. On the bright side, E2E tests generally run in CI environments.

Norfeldt commented 2 years ago

@EvanBacon No need to be sorry about anything. You have been pushing RN with expo in the right direction for years now and I admire the work you do. I'm just having a really hard time finding some good videos/tutorials/guides on how to do detox testing in a managed app (and have a CI with it).

Do you have any good reference materials on how to get started or is there any chance that you could drop a quick YT video of you showing off a very very simple detox with expo?

EvanBacon commented 2 years ago

@Norfeldt as far as I know, there aren't very good resources right now. I really don't like the current set of workarounds and hacks involved with getting Detox working so I'm not comfortable documenting them at the moment. Here is a pseudo example of using prebuild + detox in a monorepo, it's currently broken.

Somethings we're working on to fix this:

  1. You need to install expo-cli (npm i -g expo-cli) to run expo prebuild (ref). The global CLI takes a while to install and the global node modules aren't cached. To fix this, we're moving expo prebuild into the expo package so it's always versioned, cached, and fast to download.
  2. After we have a CLI interface in the expo package, we'll create a bundle and start command to override the npx react-native bundle and npx react-native start commands. This will enable us to resolve the main entry file using Node.js module resolution (i.e. respect the main field in the package.json), this will reduce the chance of error in monorepos and managed projects which tend to use node_modules/expo/AppEntry.js as the entry file.
  3. After all is working in some capacity, we can write up a step to cache the native build cache files which should introduce some nice time savings.
  4. We should add a feature to detox to automatically choose the first available simulator and emulator, right now it's unclear which devices are available and you end up having to log from the environment.

Really there are too many steps involved. E2E testing, auto screenshots, etc. would benefit a lot from some type of managed CI service.

If you manage to get an example repo working I'd love to hear your findings.

Norfeldt commented 2 years ago

@EvanBacon thank you for taking the time to clarify the current situation. Now I understand that it's not just my googling on 'react native e2e' that is bad, but it's because it's a struggle to get a stable setup (all the examples I have found has been broken).

Yes, a managed CI service would be fantastic ๐ŸŽ‰๐ŸŽ‰ and I'm crossing my fingers for Expo coming to the rescue regarding E2E testing and auto screenshots. Been looking into Appcenter from MS but not much good resources are to find on that either (but the phone farm looks cool).

Expo has been knocking down roadblock in RN land:

*tried the expo web in the hope of doing test with cypress, but I seem to beak it quickly with even simple components (don't know if it was the hot reloading or something else).