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.

Protractor & ngStorage not working together as expected

See original GitHub issue

When writing an e2e test in Protractor of behaviour that uses ngStorage, there are problems when the test refreshes the page and expects to see updated behaviour based on items persisted to localStorage.

Simple theoretical example is:

it('remains closed once dismissed', function() {
    browser.get('/');
    expect( element(by.css('.dismisable-element')).isDisplayed() ).toBe(true);

    element(by.css('.dismisable-element')).click();
    expect( element(by.css('.page-callout')).isDisplayed() ).toBe(false);

    browser.refresh();
    // FAILS
    expect( element(by.css('.dismisable-element')).isDisplayed() ).toBe(false);
});

Inserting a browser.sleep(125) before the browser.refresh() call will cause the test to pass every time. However, according to the protractor docs, this type of thing should not be necessary (http://www.protractortest.org/#/api?view=Protractor.prototype.waitForAngular).

Appears that localStorage is not being updated correctly both by the $timeout wait that protractor is supposed to do, and by the onbeforeunload handler.

There is a related discussion on stackoverflow here: https://stackoverflow.com/questions/28108148/protractor-testing-with-ngstorage/38083164#38083164

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
elishateradacommented, Nov 8, 2016

+1, we are basically switching back to native local storage method because of this

0reactions
azacharcommented, Nov 25, 2016

How about to use $interval instead $timeout? Would it help?

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Protractor testing with ngStorage - Stack Overflow
I've been having the same problem but I don't think it's related to browser.refresh() behaviour. It looks like there are timing issues with...
Read more >
azachar/ngStorage-mock: localStorage and ... - GitHub
An AngularJS module that makes Web Storage working in the Angular Way. Contains two services: $localStorage and $sessionStorage . Fork info. This fork...
Read more >
Web Libraries in Jars - WebJars
Angular Loading Bar, org.webjars, angular-loading-bar ... angular-chrome-autofill-fix, org.webjars.bower, angular-chrome-autofill-fix, 0.0.4.
Read more >
Testing with Protractor: how to fix synchronization issues
6/1.1.4 and higher - check that your version of Angular is upgraded. For AngularJS apps, the angular variable is expected to be available...
Read more >
D1.2 MaTHiSiS Exploitation Plan M24
More than one SLA, working together on the ... tackle this problem is the use of AI in mainstream education which ... ngstorage...
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