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

TestCafe modifies javascript files and throw error - variable has already been declared #2506

Closed
dilumst opened this issue Dec 11, 2020 · 2 comments · Fixed by #2547
Closed

Comments

@dilumst
Copy link

dilumst commented Dec 11, 2020

What is your Test Scenario?

running webpack bundled javascript file on Browser

What is the Current behavior?

Testcafe modified my javascript file, and throw error - variable declared twice.

I have a file - a.chunk.js which should be running on Client.
a.chunk.js works fine without any problem; however, when I hit same url via testCafe, it throw error because somehow testCafe modifies the code creating some new variables.

image

the error:
image

What is the Expected behavior?

No error should be thrown.

What is your web application and your TestCafe test code?

Your website URL (or attach your complete example):
Your complete test code (or attach your test files):
 
Your complete configuration file (if any):

Your complete test report:

Screenshots:

Steps to Reproduce:

  1. Go to my website ...
  2. Execute this command...
  3. See the error...

Your Environment details:

  • testcafe version: 1.9.4
  • node.js version: v12.18.3
  • command-line arguments: testcafe chrome test/
  • browser name and version: Chrome 87
  • platform and version: Windows 10
  • other:
@wentwrong wentwrong transferred this issue from DevExpress/testcafe Dec 11, 2020
@wentwrong
Copy link
Contributor

Thank you for the report. We modify client-side scripts so that TestCafe can manage the test page. However, in your case, there is a problem with processing a complex destructuring assignment. We'll take a look into it.

Below are the details that can help the team debug the report.
This minimal reproducible example is opened in a browser without errors:

<!DOCTYPE html>
<html>
    <body>
        <script>
            const obj = {
                context: {
                    actionContext: {
                        e: 'e prop value'
                    },
                    request: {
                        apiSettings: {
                            r: 'r prop value'
                        }
                    }
                }
            };

            const { context: { actionContext: e }, context: { request: { apiSettings: r } }} = obj;
            console.log(e);
            console.log(r);
        </script>
    </body>
</html>

However, it throws an error when it is run using Hammerhead Playground:

Uncaught SyntaxError: redeclaration of const _hh$temp0$context

@Farfurix
Copy link
Contributor

One more: #2515.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment