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

Clear out the localStorage after test #1546

Closed
LavrovArtem opened this issue Jun 19, 2017 · 4 comments
Closed

Clear out the localStorage after test #1546

LavrovArtem opened this issue Jun 19, 2017 · 4 comments
Assignees
Labels
AREA: client STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: bug The described behavior is considered as wrong (bug).
Milestone

Comments

@LavrovArtem
Copy link
Contributor

LavrovArtem commented Jun 19, 2017

Are you requesting a feature or reporting a bug?

bug

What is the current behavior?

Each test is run with the new session id. The test writes some large data into the localStorage with key generated by page url and session id. After some tests, the error occurs:

Error: Failed to set the 'hammerhead|storages-sandbox-temp' property on 'Storage': Setting the value of 'hammerhead|storages-sandbox-temp' exceeded the quota.

What is the expected behavior?

The localStorage must be cleaned after each test.

How would you reproduce the current behavior (if this is a bug)?

Tested server:

var http = require('http');

http.createServer(function (req, res) {
    if (req.url === '/') {
        res.writeHead(200, { 'Content-Type': 'text/html' });
        res.end(`
            <body>
                <script>
                    localStorage.setItem('item', new Array(1e6).join('1'));
                    setTimeout(function () {
                        document.body.appendChild(document.createElement('input'));
                        setTimeout(function () {
                            location.href = '/page';
                        }, 1000);
                    }, 1000);
                </script>
            </body>
        `);
    } else if (req.url === '/page') {
        res.writeHead(200, { 'Content-Type': 'text/html' });
        res.end('<h1>hello</h1>');
    } else {
        res.end();
    }
}).listen(8787);

Test code

fixture `Error`
    .page `http://localhost:8787/`;

for (var i = 0; i < 5; i++) {
    test('test', async t => {
        await t
            .click('input')
            .click('h1');
    });
}

image

Specify your

  • testcafe version: 0.16.0
@LavrovArtem LavrovArtem added AREA: client TYPE: bug The described behavior is considered as wrong (bug). labels Jun 19, 2017
@AlexanderMoskovkin AlexanderMoskovkin changed the title We need to clear out the localStorage after test Clear out the localStorage after test Jun 19, 2017
@AlexanderMoskovkin AlexanderMoskovkin added this to the Sprint #8 milestone Jun 19, 2017
@ww8912188
Copy link

This issue is really annoying. As a temporary workaround, I divided my tests into small pieces. Anyway, looking forward to the fix.

@AlexanderMoskovkin
Copy link
Contributor

It shouldn't take too much time to fix it and provide you with the new version

@LavrovArtem
Copy link
Contributor Author

Hi @ww8912188,
As a temporary workaround clear the localStorage after each test. You can use the afterEach test hook for this:

fixture `Tests`
    .page `http://localhost:8787/`
    .afterEach(async t => {
        await t.eval(() => localStorage.clear());
    });

@lock
Copy link

lock bot commented Mar 28, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this issue Dec 18, 2019
…evExpress#1590)

* fix `Clear out the localStorage after test` (close DevExpress#1546)

* fix review's issues
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AREA: client STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

3 participants