Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to execute e2e tests for new nx workspace with react-native preset #15455

Closed
veax opened this issue Mar 5, 2023 · 8 comments
Closed

Fail to execute e2e tests for new nx workspace with react-native preset #15455

veax opened this issue Mar 5, 2023 · 8 comments
Labels

Comments

@veax
Copy link

veax commented Mar 5, 2023

Current Behavior

I'm following official doc for react native with Nx

npx create-nx-workspace happynrwl \
--preset=react-native \
--appName=mobile

Need to install the following packages:
  create-nx-workspace@15.8.5
Ok to proceed? (y) y
Enable distributed caching to make your CI faster: Yes

Running application on android elumator without any errors:

cd happynrwl
npx nx run-android mobile

Execution logs:

> Task :app:installDebug
Installing APK 'app-debug.apk' on 'Pixel_3a_API_30(AVD) - 11' for :app:debug
Installed on 1 device.

BUILD SUCCESSFUL in 21s
89 actionable tasks: 89 executed
info Connecting to the development server...
8081
info Starting the app on "emulator-5554"...
Starting: Intent { cmp=com.mobile/.MainActivity }
 BUNDLE  src/main.tsx

 LOG  Running "Mobile" with {"rootTag":11}

Running e2e tests with errors:

npx nx test-android mobile-e2e --verbose

> nx run mobile-e2e:test-android
 >  NX   Cannot read properties of undefined (reading 'executor')

TypeError: Cannot read properties of undefined (reading 'executor')
    at readTargetOptions (/Users/veax/Dev/sandbox/happynrwl/node_modules/@nrwl/devkit/src/executors/read-target-options.js:18:60)
    at detoxTestExecutor_1 (/Users/veax/Dev/sandbox/happynrwl/node_modules/@nrwl/detox/src/executors/test/test.impl.js:16:69)
    at detoxTestExecutor_1.next (<anonymous>)
    at resume (/Users/veax/Dev/sandbox/happynrwl/node_modules/tslib/tslib.js:279:48)
    at /Users/veax/Dev/sandbox/happynrwl/node_modules/tslib/tslib.js:278:125
    at new Promise (<anonymous>)
    at Object.i.<computed> [as next] (/Users/veax/Dev/sandbox/happynrwl/node_modules/tslib/tslib.js:278:67)
    at /Users/veax/Dev/sandbox/happynrwl/node_modules/nx/src/command-line/run.js:53:35
    at Generator.next (<anonymous>)
    at /Users/veax/Dev/sandbox/happynrwl/node_modules/tslib/tslib.js:167:75

 ——————————————————————————————————————————————————————————————————————————————

 >  NX   Running target test-android for project mobile-e2e failed

   Failed tasks:

   - mobile-e2e:test-android

Expected Behavior

Execute detox e2e tests out of the box

GitHub Repo

https://github.com/veax/nx-react-native-issue

Steps to Reproduce

  1. Create monorepo:
npx create-nx-workspace happynrwl \
--preset=react-native \
--appName=mobile
  1. Run app:
cd happynrwl
npx nx run-android mobile

also tried npx nx start mobile according to E2E Testing with Nx React Native

  1. Run e2e
npx nx test-android mobile-e2e

Nx Report

>  NX   Report complete - copy this into the issue template

   Node : 16.19.0
   OS   : darwin arm64
   npm  : 8.19.3

   nx                      : 15.8.5
   @nrwl/js                : 15.8.5
   @nrwl/jest              : 15.8.5
   @nrwl/linter            : 15.8.5
   @nrwl/workspace         : 15.8.5
   @nrwl/cli               : 15.8.5
   @nrwl/detox             : 15.8.5
   @nrwl/devkit            : 15.8.5
   @nrwl/eslint-plugin-nx  : 15.8.5
   @nrwl/react             : 15.8.5
   @nrwl/react-native      : 15.8.5
   @nrwl/tao               : 15.8.5
   @nrwl/nx-cloud          : 15.1.1
   typescript              : 4.9.5

Failure Logs

> nx run mobile-e2e:test-android


 >  NX   Cannot read properties of undefined (reading 'executor')


TypeError: Cannot read properties of undefined (reading 'executor')
    at readTargetOptions (/Users/veax/Dev/sandbox/happynrwl/node_modules/@nrwl/devkit/src/executors/read-target-options.js:18:60)
    at detoxTestExecutor_1 (/Users/veax/Dev/sandbox/happynrwl/node_modules/@nrwl/detox/src/executors/test/test.impl.js:16:69)
    at detoxTestExecutor_1.next (<anonymous>)
    at resume (/Users/veax/Dev/sandbox/happynrwl/node_modules/tslib/tslib.js:279:48)
    at /Users/veax/Dev/sandbox/happynrwl/node_modules/tslib/tslib.js:278:125
    at new Promise (<anonymous>)
    at Object.i.<computed> [as next] (/Users/veax/Dev/sandbox/happynrwl/node_modules/tslib/tslib.js:278:67)
    at /Users/veax/Dev/sandbox/happynrwl/node_modules/nx/src/command-line/run.js:53:35
    at Generator.next (<anonymous>)
    at /Users/veax/Dev/sandbox/happynrwl/node_modules/tslib/tslib.js:167:75

 ——————————————————————————————————————————————————————————————————————————————

 >  NX   Running target test-android for project mobile-e2e failed

   Failed tasks:

   - mobile-e2e:test-android

   Hint: run the command with --verbose for more details.

   View structured, searchable error logs at https://nx.app/runs/Q31jdURdTR

Additional Information

Running on Mac M1 macOS Ventura 13.2.1

node -v
v16.19.0
@veax veax added the type: bug label Mar 5, 2023
@mandarini mandarini added the scope: react-native Issues relating to React Native label Mar 6, 2023
@veax
Copy link
Author

veax commented Mar 11, 2023

There is a typo "}" in mobile-e2e/project.json:

"test-android": {
      "executor": "@nrwl/detox:test",
      "options": {
        "detoxConfiguration": "android.emu.debug",
        "buildTarget": "mobile-e2e:build-android}"  <-- "}"
      },
      "configurations": {
        "production": {
          "detoxConfiguration": "android.emu.release",
          "buildTarget": "mobile-e2e:build-android:production"
        }
      }
    },

After fixing this, I have another error "No instrumentation runner found on device emulator":

npx nx test-android mobile-e2e

> nx run mobile-e2e:test-android

Detected a deprecated "runnerConfig" property (string).
Detected a deprecated "testRunner" property (string).
Please migrate your Detox config according to the guide:
https://wix.github.io/Detox/docs/guide/migration

cd ../../apps/mobile/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug

> Configure project :app
Reading env from: .env
**************************
*** Missing .env file ****
**************************

BUILD SUCCESSFUL in 2s
218 actionable tasks: 1 executed, 217 up-to-date
Detected a deprecated "runnerConfig" property (string).
Detected a deprecated "testRunner" property (string).
Please migrate your Detox config according to the guide:
https://wix.github.io/Detox/docs/guide/migration

17:12:06.907 detox[12036] B jest --config jest.config.json
17:12:08.062 detox[12037] i app.spec.ts is assigned to emulator-14716 (Pixel_4a_API_30)
17:12:08.167 detox[12037] i Mobile: should display welcome message
17:12:08.167 detox[12037] i Mobile: should display welcome message [FAIL]

 FAIL  src/app.spec.ts
  Mobile
    ✕ should display welcome message (1 ms)

  ● Mobile › should display welcome message

    No instrumentation runner found on device emulator-14716 for package com.mobile

      2 |
      3 | beforeAll(async () => {
    > 4 |   await device.launchApp();
        |                ^
      5 | });
      6 |

      at Object.launchApp (test-setup.ts:4:16)

17:12:08.292 detox[12036] E Command failed with exit code = 1:
jest --config jest.config.json

 >  NX   1



 ——————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target test-android for project mobile-e2e (5s)

    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]

Note: e2e tests works if I execute command:

cd mobile-e2e 
npx detox test --configuration android.emu.debug

@leobastiani
Copy link
Contributor

leobastiani commented Mar 12, 2023

I'm facing the same issue but I ran

npx create-nx-workspace happynrwl \
--preset=react-native \
--appName=mobile --packageManager yarn

@jeremiahlachica
Copy link

I experience the same issue. Do we have updates to this?

@leobastiani
Copy link
Contributor

I saw reuse is true by default
image

@leobastiani
Copy link
Contributor

I think --verbose should output what is going to be run

childProcess = fork(
join(workspaceRoot, './node_modules/detox/local-cli/cli.js'),
['test', ...createDetoxTestOptions(options)],
{
cwd: join(workspaceRoot, projectRoot),
}
);

I see other places using fork as well that could have this change

@xiongemi
Copy link
Collaborator

I think --verbose should output what is going to be run

childProcess = fork(
join(workspaceRoot, './node_modules/detox/local-cli/cli.js'),
['test', ...createDetoxTestOptions(options)],
{
cwd: join(workspaceRoot, projectRoot),
}
);

I see other places using fork as well that could have this change

you can run the command with --verbose flag like nx test-ios ... --verbose

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

Copy link

github-actions bot commented Dec 8, 2023

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants