Search code examples
javascriptelectroncreate-react-appe2e-testingtestcafe

test cafe + electron + create-react-app not loading bundle.js properly


I'm running into an issue where I cannot get testcafe to load properly. It starts the testcafe service and loads the index.html file but the bundle never loads so any DOM selection fails as it is not available.

because of create-react-app, we've got a varied folder structure from the examples that I would like not to deviate from.

folder structure

|-_e2eTest
|--...testFiles
|-build
|-public
|--index.html
|-src
|--index.js
|--electron-starter.js
|-.testcafe-electron-rc
|-package.json

package.json

{
...
  "main": "./src/electron-starter.js",
  "scripts": {
    ...
    "testcafe": "testcafe electron:. ./_e2eTest/**/*.js"
    ...
  }
}

.testcafe-electron-rc

{
  "mainWindowUrl": "./build/index.html", // works similarly with "./public/index.html"
  "appPath": "./"
}

links for reference

https://github.com/DevExpress/testcafe-browser-provider-electron

https://github.com/DevExpress/testcafe-browser-provider-electron/issues/25

https://github.com/DevExpress/testcafe-browser-provider-electron/issues/30


Solution

  • I created a sample React+Electron project following this guide and didn't face any issue with TestCafe integration.

    I can only suppose that there is an error somewhere in configuration, so I'll appreciate it if you provide us with your project. In this case, I'll be able to research the issue in detail. Please create a separate issue on GitHub using the following form