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

JS modified in wrong manner #7415

Closed
tandreys opened this issue Dec 8, 2022 · 5 comments
Closed

JS modified in wrong manner #7415

tandreys opened this issue Dec 8, 2022 · 5 comments
Labels
FREQUENCY: level 1 STATE: Need clarification An issue lacks information for further research. STATE: possibly fixed in native automation SYSTEM: hammerhead TYPE: bug The described behavior is considered as wrong (bug).

Comments

@tandreys
Copy link

tandreys commented Dec 8, 2022

What is your Scenario?

Some functions are failing only under Testcafe.
Take that code
var a=0;
var b = function(){
a++;
return a;
}
var t={1: 0, 2:0};
for (var i=0;i<2;i++){
t[b()] +=1;
}
console.log(a);
console.log(t);

What is the Current behavior?

a=0;
var b = function(){
a++;
return a;
}
var t={1: 0, 2:0};
for (var i=0;i<2;i++){
__set$(t,b(),__get$(t,b())+1) ;
}
console.log(a);
console.log(t);

giving
4

Object {1:1, 2: 0, 3:NaN}

What is the Expected behavior?

2
Object { 1: 1, 2: 1 }

What is your public website URL? (or attach your complete example)

<script> var a=0; var b = function(){ a++; return a; } var t={1: 0, 2:0}; for (var i=0;i<2;i++){ t[b()] +=1; } console.log(a); console.log(t); </script>

What is your TestCafe test code?

fixture Sandbox

test('repro', async t => {
await t.navigateTo("file:///C:/temp/repro.html");

await t.debug();

})

Your complete configuration file

No response

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

TestCafe version

2.1.0

Node.js version

tried with latest 14,16 and 18

Command-line arguments

testcafe "chrome" repro.js -d

Browser name(s) and version(s)

chrome, firefox, edge

Platform(s) and version(s)

Windows 11, Ubuntu 20

Other

you can see t[b()] += 1; is transformed to __set$(t,b(),__get$(t,b())+1), and the value of a is not expected in testcafe, because the function b is not idempotent (it changes a every time).

@tandreys tandreys added the TYPE: bug The described behavior is considered as wrong (bug). label Dec 8, 2022
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Dec 8, 2022
@AlexKamaev
Copy link
Contributor

AlexKamaev commented Dec 9, 2022

Thank you for reporting this. I was able to reproduce the issue.

Please also read about the new TestCafe option that is available in the https://www.npmjs.com/package/testcafe/v/2.1.1-alpha.2 version and newer.

TestCafe runs tests using the URL-rewritten proxy.
This approach is good. However, there is a way to improve the stability and speed of test execution - the native browser automation API.
We have a test execution mode uses native browser automation - we call it the Proxyless mode.
In Proxyless mode, a few issues are already fixed.
By the way, this issue was also fixed in Proxyless mode.
Try running your tests in Proxyless mode and let us know the results.
This option is available in all interfaces:

// Command-line
testcafe chrome tests --experimental-proxyless
// Programmatic
const testcafe = await createTestCafe({ experimentalProxyless: true });

// Configuration file
{
"experimentalProxyless": "true"
} 

Note that at present it is an experimental mode.
Also, the Proxyless mode is implemented only in Google Chrome. It will not work correctly if you run tests in a non-Chrome browser or in a combination of other browsers.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Dec 9, 2022
@tandreys
Copy link
Author

tandreys commented Dec 9, 2022

Hi,
I'm not able to launch test in proxyless mode
ERROR Unable to open the "chrome:" browser due to the following error:

TypeError: Cannot read properties of undefined (reading 'Fetch')
at Proxyless.init (C:\testcafe\node_modules\testcafe\src\proxyless\index.ts:28:28)
at BrowserProviderPluginHost._setupProxyless (C:\testcafe\node_modules\testcafe\src\browser\provider\built-in\dedicated\chrome\index.js:53:25)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at BrowserProviderPluginHost.openBrowser (C:\testcafe\node_modules\testcafe\src\browser\provider\built-in\dedicated\chrome\index.js:96:13)
at BrowserProvider.openBrowser (C:\testcafe\node_modules\testcafe\src\browser\provider\index.ts:323:9)
at BrowserConnection._runBrowser (C:\testcafe\node_modules\testcafe\src\browser\connection\index.ts:258:13)

I'm on Windows 11, Chrome 108

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Dec 9, 2022
@tandreys
Copy link
Author

tandreys commented Dec 9, 2022

it's a node issue, I was using NodeJS 18.
Reverting to node 14, I'm able to launch it and manually checking that the issue does not occur.

But my test is failing on login page.
await t
.typeText('#j_username', name)
.typeText('#j_password', password)
.click('#logOnFormSubmit');

The click on submit is working, page is loading but Testcafe is still searching for the button and is failing.
The same code without proxyless mode is working fine.

In an other test, it's failing on .beforeEach
Error in fixture.beforeEach hook -
TypeError: Cannot read property 'proxy' of null

@miherlosev
Copy link
Collaborator

Hi @tandreys

it's a node issue, I was using NodeJS 18.

Yes, we have a known issue related to the Node.js@18.x version.

But my test is failing on login page.
await t
.typeText('#j_username', name)
.typeText('#j_password', password)
.click('#logOnFormSubmit');

Could you please share a simple example that we can run locally?

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Dec 12, 2022
@AndreyBelym AndreyBelym added the STATE: Need clarification An issue lacks information for further research. label Dec 16, 2022
@github-actions
Copy link

This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FREQUENCY: level 1 STATE: Need clarification An issue lacks information for further research. STATE: possibly fixed in native automation SYSTEM: hammerhead TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

4 participants