question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unable to select in production/staging build

See original GitHub issue

I’m getting the following errors when running test for production build, while those pass on local dev build.

Error: testcafe-react-selectors supports React version 15.x and newer

1) The specified selector does not match any element in the DOM tree.

      Browser: Electron 1.7.5 / Mac OS X 10.12.6

I’m currently using preact in production, but tested with it disabled as well, where still gets the following errors

1) The specified selector does not match any element in the DOM tree.

The react classname is uglified in my production build, which leads to the selector to be invalid.

Was wondering if there’s a workaround to get it work with production/staging build?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15

github_iconTop GitHub Comments

3reactions
amilajackcommented, Aug 6, 2018

SOLUTION: If you are using webpack>=4, add this to your webpack production config:

{
  // ...
  optimization: {
    minimizer: []
  }
}

Here is a reproducible example of this:

git clone https://github.com/amilajack/erb-testcafe-example
cd erb-testcafe-example
git checkout add-testcafe-react-selectors
yarn
# Run production build
yarn build
# Run e2e tests against production build
yarn test-e2e

Errors:

 ✖ should navgiate to /counter

   1) The specified selector does not match any element in the DOM tree.

      Browser: Electron 2.0.2 / Mac OS X 10.13.6

         40 |});
         41 |
         42 |test('should navgiate to /counter', async t => {
         43 |  await waitForReact();
         44 |  await t
       > 45 |    .click(ReactSelector('Link').withProps({
         46 |      to: '/counter'
         47 |    }))
         48 |    .expect(getPageUrl())
         49 |    .contains('/counter');
         50 |});

Failing test

test('should navgiate to /counter', async t => {
  await waitForReact();
  await t
    .click(
      ReactSelector('Link').withProps({
        to: '/counter'
      })
    )
    .expect(getPageUrl())
    .contains('/counter');
});

See the diff for this here

I am using webpack to package the production build.

UPDATE: works if i change webpack config mode to 'development'. Also even if i add the recommended uglify settings to the app, that doesn’t fix the issue. I’m thinking the issue has to do with webpack’s default minification in webpack 4. Here is the fix

0reactions
kirovboriscommented, May 21, 2018

I’m closing this issue because no activity has been encountered for a long time. Feel free to reopen the issue if the problem persists and you can provide an example to reproduce it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to configure independent sets of runtime settings in Xcode
In this case you propose to create new build configurations to select appropriate runtime settings. Build configurations are for the build phase ...
Read more >
Sites and Environments - Support Center - WP Engine
Learn how to create and use Sites as well as Production, Staging and Development ... Select the Environment type for this new environment....
Read more >
Where Should You Tune Queries: Production, Staging, or ...
The #1 fastest way to tune queries is in the production database, on the production server. I know. Put the knife down.
Read more >
Troubleshooting - Strapi Developer Docs
Below are answers and solutions to most common issues that you may experience when working with Strapi. # Why can't I create or...
Read more >
Managing Production and Development Settings in ASP.NET ...
ASP.NET Core provides three tools for managing your application's configuration. At a course-grained level, you can select your appsettings file ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found