ouihealth/detox-puppeteer

TypeError: Cannot destructure property 'debugSynchronization' of 'undefined' as it is undefined

Closed this issue · 10 comments

Terminal

detox test --configuration web

detox[99692] INFO:  [test.js] DETOX_CONFIGURATION="web" DETOX_REPORT_SPECS=true DETOX_START_TIMESTAMP=1625845882176 DETOX_USE_CUSTOM_LOGGER=true jest --config __tests__/e2e/config.json --maxWorkers 1 e2e
detox[99694] ERROR: TypeError: Cannot destructure property 'debugSynchronization' of 'undefined' as it is undefined.
    at new Client (/Users/adamhari/Projects/ts-invoices-app/node_modules/detox/src/client/Client.js:22:17)
    at new PuppeteerTestee (/Users/adamhari/Projects/ts-invoices-app/node_modules/detox-puppeteer/src/PuppeteerDriver.ts:136:19)
    at new PuppeteerDriver (/Users/adamhari/Projects/ts-invoices-app/node_modules/detox-puppeteer/src/PuppeteerDriver.ts:742:19)
    at Detox._doInit (/Users/adamhari/Projects/ts-invoices-app/node_modules/detox/src/Detox.js:161:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

.detoxrc.json

{
  "testRunner": "jest",
  "runnerConfig": "__tests__/e2e/config.json",
  "apps": {
    "web": {
      "binaryPath": "http://localhost:8080/"
    }
  },
  "devices": {
    "browser": {
      "type": "detox-puppeteer",
      "defaultViewport": {
        "width": 375,
        "height": 712
      },
      "headless": false,
      "devtools": false
    }
  },
  "configurations": {
    "web": {
      "device": "browser",
      "app": "web"
    }
  }
}

config.json

{
    "testEnvironment": "./environment",
    "testRunner": "jest-circus/runner",
    "testTimeout": 120000,
    "testRegex": "\\.e2e\\.js$",
    "reporters": ["detox/runners/jest/streamlineReporter"],
    "verbose": true
}

environment.js

const {
  DetoxCircusEnvironment,
  SpecReporter,
  WorkerAssignReporter,
} = require('detox/runners/jest-circus');

class CustomDetoxEnvironment extends DetoxCircusEnvironment {
  constructor(config, context) {
    super(config, context);

    // Can be safely removed, if you are content with the default value (=300000ms)
    this.initTimeout = 300000;

    // This takes care of generating status logs on a per-spec basis. By default, Jest only reports at file-level.
    // This is strictly optional.
    this.registerListeners({
      SpecReporter,
      WorkerAssignReporter,
    });
  }
}

module.exports = CustomDetoxEnvironment;

Dependencies

"detox": "^18.18.1",
"detox-puppeteer": "^3.0.4",
"jest": "^26.6.3",
"jest-circus": "^27.0.6",

Sorry I haven't responded to this sooner! I dont appear to be getting email notifications for this repository. At first glance I'm not sure what may be wrong. I haven't tested detox-puppeteer with either detox 18 or with the new-ish config format.

I'm a little busy at work, so not sure when I'll be able to get to this, but it's on my radar!

Looking forward to it @awinograd!

I was able to get detox-puppeteer running with my project after i downgraded detox to 17.x, jest-circus to 26.x, and after I migrated my config into the package.json to match this library's readme.

Now my issue is that the by.id matcher doesn't seem to be working as expected. I have some e2e tests that pass on iOS and Android, but am getting a performing action on undefined element error on web for

        17 |       await waitFor(element(by.id('InvoiceFormContainer'))).toBeVisible();
      > 18 |       await element(by.id('InvoiceFormContainer')).scroll(400, 'down');

I verified in the DOM that the data-testid attribute is present for that element so I'm not sure what to make of it.

@adamhari does that error show for you constantly? or is it intermittent / flaky? If you are able send over a production where this consistently errors for you, that would be helpful for me in debugging the root cause.

i've been seeing that error intermittently. Even though the element exists in the DOM, it doesn't seem to get matched by puppeteer for some reason. I have a local fix i've been testing out the past week or two that makes it much less common, but it still pops up on occasion. I just published version 3.0.5 which includes that "workaround" so you may have more success there.

It gets that error consistently for me on 3.0.4 and 3.0.5. I was able to resolve it by adding a withTimeout() to the waitFor command above it. I found that Detox will give a false positive for my waitFor command unless I include the timeout (probably related to this).

ok, glad you were able to get it working. if you run into further issues, please let me know

I get the same error message but could we upgrade to detox 18? @awinograd

Hi @Jonatthu unfortunately there appear to be quite a number of breaking changes b/t detox 17 & 18. I dont currently have the bandwidth to identify and work through them. I'll update this issue when I have a chance to support detox 18

Hi @adamhari and @Jonatthu,

I just published version 3.1.1 of detox-puppeteer which should be compatible with detox 18. Please let me know if you run into any issues upgrading

Hi @awinograd,

It's working well for me so far. I changed my Detox config to use a separate file with the new format which specifies apps and devices separately and noticed that the PuppeteerDriver will fail in validateDeviceConfig because of a missing binaryPath when I include it in the app object. It works when I include binaryPath in the device object or the config object itself, but expected it to work on the app object for consistency with native platform configs.

configuration.throwOnEmptyBinaryPath();

hi @adamhari

thanks for the feedback. I just pushed version 3.2.0 which should be compatible with the new configuration format