DevExpress / testcafe

A Node.js tool to automate end-to-end web testing.
https://testcafe.io
MIT License
9.82k stars 670 forks source link

Bug processing private fields in hammerhead #7238

Closed felis2803 closed 1 year ago

felis2803 commented 2 years ago

What is your Scenario?

Testing an application containing a class with private fields.

What is the Current behavior?

The browser console gives the following result of the application when it is launched from TestCafe: изображение

What is the Expected behavior?

The same application run without TestCafe gives a different result: изображение

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

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function fn (resolve) {
            setTimeout(resolve, 400, 42);
        }

        class CL {
            static #promise;

            static async #fn1 () {
                const value = await this.#promise;

                console.log(`should be eql 42: ${value}`);
            }

            static fn2 () {
                this.#promise = new Promise(resolve => fn(resolve));

                this.#fn1();
            }
        }

        CL.fn2();
    </script>
</body>
</html>

What is your TestCafe test code?

import { Selector } from 'testcafe';

fixture `New Fixture`
    .page `path/to/app`;

test(`New Test`, async t => {
    await t.debug();
});

TestCafe version

1.20.1-rc.2

Command-line arguments

testcafe chrome test.js

tikabom commented 2 years ago

I raised a similar issue that I guess would be the same as this one.. Is this being actively looked into for resolution? What's the current status?

github-actions[bot] commented 2 years ago

No updates yet. Once we get any results, we will post them in this thread.

miherlosev commented 1 year ago

Hi folks,

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.

miherlosev commented 1 year ago

Fixed in https://github.com/DevExpress/testcafe-hammerhead/pull/2883