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

TypeError: Cannot read properties of undefined (reading 'default') #4042

Closed
1 of 2 tasks
mklb opened this issue May 5, 2023 · 7 comments
Closed
1 of 2 tasks

TypeError: Cannot read properties of undefined (reading 'default') #4042

mklb opened this issue May 5, 2023 · 7 comments

Comments

@mklb
Copy link

mklb commented May 5, 2023

What happened?

Test that used to run (below version 20.0.0) do not run anymore.

 FAIL  e2e/01_freeVersionTest.e2e.js
  ● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'default')

      4 | // ...
      5 |
    > 6 | beforeAll(async () => {
        |          ^
      7 |   // launches the app with notifications permission
      8 |   await device.launchApp({permissions: {notifications: 'YES'}, delete: true})
      9 | })

      at Object.default (e2e/01_freeVersionTest.e2e.js:6:10)

What was the expected behaviour?

Run the test

Was it tested on latest Detox?

  • I have tested this issue on the latest Detox release and it still reproduces.

Did your test throw out a timeout?

Help us reproduce this issue!

No response

In what environment did this happen?

Detox version: 20.7.2
React Native version: 0.71.6
Has Fabric (React Native's new rendering system) enabled: no
Node version: 16.17.0
Device model: iPhone 14
iOS version: 16.4
macOS version: 13.3.1
Xcode version: 14.3
Test-runner (select one): jest

Detox logs

Detox logs
$ npm run detox-ios-run-log      

> MyAppName@0.0.1 detox-ios-run-log
> detox test --configuration ios.dev --loglevel trace

17:27:06.258 detox[29193] B lifecycle node_modules/.bin/detox test --configuration ios.dev --loglevel trace
  data: {
    "id": "75458704-dee8-e190-ec89-db5179f0de21",
    "detoxConfig": {
      "configurationName": "ios.dev",
      "apps": {
        "MyAppName": {
          "type": "ios.app",
          "name": "MyAppName",
          "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/MyAppName.app",
          "build": "set -o pipefail && xcodebuild -workspace ios/MyAppName.xcworkspace -UseNewBuildSystem=YES -scheme MyAppName -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
          "bundleId": "club.MyAppName.ios"
        }
      },
      "artifacts": {
        "rootDir": "artifacts/ios.dev.2023-05-05 15-27-06Z",
        "plugins": {
          "log": {
            "enabled": false,
            "keepOnlyFailedTestsArtifacts": false
          },
          "screenshot": {
            "enabled": true,
            "shouldTakeAutomaticSnapshots": false,
            "keepOnlyFailedTestsArtifacts": false
          },
          "video": {
            "enabled": false,
            "keepOnlyFailedTestsArtifacts": false
          },
          "instruments": {
            "enabled": false,
            "keepOnlyFailedTestsArtifacts": false
          },
          "uiHierarchy": {
            "enabled": false,
            "keepOnlyFailedTestsArtifacts": false
          }
        }
      },
      "behavior": {
        "init": {
          "keepLockFile": false,
          "reinstallApp": true,
          "exposeGlobals": true
        },
        "cleanup": {
          "shutdownDevice": false
        },
        "launchApp": "auto"
      },
      "cli": {
        "configuration": "ios.dev",
        "loglevel": "trace",
        "start": true
      },
      "device": {
        "type": "ios.simulator",
        "device": {
          "type": "iPhone 14 Pro",
          "os": "iOS 16.2"
        }
      },
      "logger": {
        "level": "trace",
        "overrideConsole": true,
        "options": {
          "showLoggerName": true,
          "showPid": true,
          "showLevel": false,
          "showMetadata": false,
          "basepath": "/Users/myname/Github/MyAppName/node_modules/detox/src",
          "prefixers": {},
          "stringifiers": {}
        }
      },
      "testRunner": {
        "retries": 0,
        "forwardEnv": false,
        "bail": false,
        "jest": {
          "setupTimeout": 300000,
          "teardownTimeout": 30000,
          "retryAfterCircusRetries": false,
          "reportWorkerAssign": true
        },
        "args": {
          "$0": "jest",
          "_": [
            "e2e"
          ],
          "config": "./e2e/config.json",
          "--": []
        },
        "$0": "jest"
      },
      "session": {
        "autoStart": true,
        "debugSynchronization": 10000
      }
    },
    "detoxIPCServer": "primary-29193",
    "testResults": [],
    "testSessionIndex": 0,
    "workersCount": 0
  }
17:27:06.267 detox[29193] i ipc Server path not specified, so defaulting to ipc.config.socketRoot + ipc.config.appspace + ipc.config.id /tmp/detox.primary-29193
17:27:06.269 detox[29193] i ipc starting server on  /tmp/detox.primary-29193 
17:27:06.269 detox[29193] i ipc starting TLS server false
17:27:06.269 detox[29193] i ipc starting server as Unix || Windows Socket
17:27:06.272 detox[29193] i ws-server Detox server listening on localhost:60071...
17:27:06.272 detox[29193] i lifecycle Serialized the session state at: /private/var/folders/h4/_83g_kmd4n95pgktq_06sbpr0000gn/T/75458704-dee8-e190-ec89-db5179f0de21.detox.json
17:27:06.273 detox[29193] B lifecycle jest --config ./e2e/config.json e2e
 FAIL  e2e/01_freeVersionTest.e2e.js
  ● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'default')

      4 | // ...
      5 |
    > 6 | beforeAll(async () => {
        |          ^
      7 |   // launches the app with notifications permission
      8 |   await device.launchApp({permissions: {notifications: 'YES'}, delete: true})
      9 | })

      at Object.default (e2e/01_freeVersionTest.e2e.js:6:10)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.196 s
Ran all test suites matching /e2e/i.
17:27:07.676 detox[29193] E lifecycle Command failed with exit code = 1:
jest --config ./e2e/config.json e2e
17:27:07.677 detox[29193] i ws-server Detox server has been closed gracefully
17:27:07.678 detox[29193] E lifecycle node_modules/.bin/detox test --configuration ios.dev --loglevel trace

Device logs

No response

More data, please!

.babelrc

{
  "presets": [
    "module:metro-react-native-babel-preset",
    "@babel/preset-flow"
  ],
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy": true }]
  ],
  "env": {
    "production": {
      "plugins": ["transform-remove-console"]
    }
  }
}

./.e2e/config.json

{
    "preset": "react-native",
    "moduleDirectories": [
      "node_modules"
    ],
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ],
    "automock": true,
    "maxWorkers": 1,
    "testRunner": "jest-circus/runner",
    "testTimeout": 60000,
    "rootDir": "..",
    "testMatch": ["<rootDir>/e2e/*.e2e.js"],
    "verbose": true,
    "transformIgnorePatterns": [
      "node_modules/(?!((jest-)?react-native(-.*)?|rn(-.*)?|@react-native(-community)?)/)"
    ],
    "transform": {
        "^.+\\.[t|j]sx?$": [
          "babel-jest",
          {
            "configFile": "./.babelrc"
          }
        ]
      }
}

@noomorph
Copy link
Collaborator

noomorph commented May 5, 2023

This is most likely a problem with jest or your babel transformations.

Could you run npm ls jest from inside your project?

@noomorph
Copy link
Collaborator

noomorph commented May 5, 2023

Are you trying to upgrade Detox from 19 to 20?

@noomorph
Copy link
Collaborator

noomorph commented May 5, 2023

Btw your jest config does not look compliant to Detox 20. Read the migration steps.

If possible, avoid using react-native preset for Detox tests.

@mklb
Copy link
Author

mklb commented May 7, 2023

@noomorph thanks for the tip. Yes, I tried to upgrade. I ran detox init, got a correct config now and the error is gone. However there is a new one now:

The app crashes during startup (in dev and production build). When I click on the build app in the simulator afterwards, it just opens up fine. So the crash is not related to the app itself (also, tests run before upgrading to 20).

   The pending request #-1000 ("isReady") has been rejected due to the following error:

    The app has crashed, see the details below:

    Signal 11 was raised
    (
    	0   Detox                               0x0000000104747a80 +[NSThread(DetoxUtils) dtx_demangledCallStackSymbols] + 36
    	1   Detox                               0x000000010474a690 __DTXHandleCrash + 440
    	2   Detox                               0x000000010474acc0 __DTXHandleSignal + 72
    	3   libsystem_platform.dylib            0x00000001b182dce0 _sigtramp + 52
    	4   DetoxSync                           0x000000010fe2c538 -[_DTXTimerTrampoline setDisplayLink:] + 96
    	5   DetoxSync                           0x000000010fe2c538 -[_DTXTimerTrampoline setDisplayLink:] + 96
    	6   DetoxSync                           0x000000010fe29cf8 +[DTXTimerSyncResource _timerProxyWithDisplayLink:] + 92
    	7   DetoxSync                           0x000000010fe29da8 +[DTXTimerSyncResource existingTimerProxyWithDisplayLink:create:] + 152
    	8   DetoxSync                           0x000000010fe1fa9c +[DTXSyncManager trackDisplayLink:name:] + 84
    	9   DetoxSync                           0x000000010fe1308c -[NSObject(REANodesManagerDTXSpy) __detox_sync_startUpdatingOnAnimationFrame] + 104
    	10  MyApp                               0x000000010102bef8 -[REANodesManager postRunUpdatesAfterAnimation] + 60
    	11  MyApp                               0x000000010102b328 -[REANode markUpdated] + 100
    	12  MyApp                               0x000000010102acac -[REANode dangerouslyRescheduleEvaluate] + 124
    	13  MyApp                               0x000000010102b23c -[REANode addChild:] + 156
    	14  MyApp                               0x000000010102d1e4 -[REANodesManager connectNodes:childID:] + 816
    	15  MyApp                               0x0000000101029658 __35-[REAModule connectNodes:childTag:]_block_invoke + 76
    	16  MyApp                               0x000000010102a5fc __42-[REAModule uiManagerWillPerformMounting:]_block_invoke + 288
    	17  MyApp                               0x000000010117bf30 __44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke + 288
    	18  MyApp                               0x000000010117c1f4 __44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke.206 + 376
    	19  MyApp                               0x000000010118383c __RCTExecuteOnMainQueue_block_invoke + 40
    	20  DetoxSync                           0x000000010fe14454 ____detox_sync_dispatch_wrapper_block_invoke + 44
    	21  libdispatch.dylib                   0x0000000180132ee4 _dispatch_call_block_and_release + 24
    	22  libdispatch.dylib                   0x0000000180134708 _dispatch_client_callout + 16
    	23  libdispatch.dylib                   0x0000000180143fd8 _dispatch_main_queue_drain + 1220
    	24  libdispatch.dylib                   0x0000000180143b04 _dispatch_main_queue_callback_4CF + 40
    	25  CoreFoundation                      0x000000018039a784 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
    	26  CoreFoundation                      0x0000000180394de4 __CFRunLoopRun + 1912
    	27  CoreFoundation                      0x0000000180394254 CFRunLoopRunSpecific + 584
    	28  GraphicsServices                    0x0000000188eb7c9c GSEventRunModal + 160
    	29  UIKitCore                           0x00000001109baff0 -[UIApplication _run] + 868
    	30  DetoxSync                           0x000000010fe1a8fc __detox_sync_UIApplication_run + 376
    	31  UIKitCore                           0x00000001109bef3c UIApplicationMain + 124
    	32  MyApp                               0x0000000100db306c main + 100
    	33  dyld                                0x00000001046a1514 start_sim + 20
    	34  ???                                 0x00000001048d1f28 0x0 + 4371324712
    	35  ???                                 0x6625800000000000 0x0 + 7360429903495299072
    )

       7 |   beforeAll(async () => {
       8 |     // launches the app with notifications permission
    >  9 |     await device.launchApp({permissions: {notifications: 'YES'}, delete: true})
         |                  ^
      10 |   })

Crash looks similar to #2706 , #3792 and #3521

It seems that the metro bundle is never executed, so it crashes. All I see is a white screen. The Metro server shows no logs or indication that code is executed. When I click on the app after the crash, it launches fine and produces logs.

@mklb
Copy link
Author

mklb commented May 15, 2023

I updated Detox to 20.9.0 and still see the same errorThe pending request #-1000 ("isReady") has been rejected. Maybe this is ticket is also related: #3207

@stale
Copy link

stale bot commented Jun 15, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

@stale stale bot added the 🏚 stale label Jun 15, 2023
@stale
Copy link

stale bot commented Jul 15, 2023

The issue has been closed for inactivity.

@stale stale bot closed this as completed Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants