Well, during approximately 30-40 hours of researching this seemingly tiny and simple operation in the last 2 weeks, I've been
directed to e2e mocks. I've been
directed to injection. I've been
directed to services ... etc ... all of which have resulted in hours of reading, searching, and trying to learn a sprawling mess of new concepts and so on.
If I can't find a simple piece of actual code that proves this is possible soon, we'll need to ditch Angular E2E altogether for our testing and switch to Selenium. :(
Maybe there's a better way to do it, but if I can get the code to wait until an asynchronous item is 'fulfilled', then assign the value of it to a variable and then proceed with some functionality, then I'm all set. I don't care if it has to wait 1,2,5 or 10 seconds for everything to be fulfilled - the speed of an e2e test is far less important than it's usefulness, so I don't care if it sits doing nothing for 50 seconds to be sure the future has resolved.
I thought this would work (and variations of it) ... but it just never returns anything:
setTimeout(function() {console.log(element('a').text()}, 10000); // or any length of time.
... or this, but it just returns 'undefined´, which suggests the callback function is just running immediately:
return element('li a').text().value;
}()); // removing the () just dumps a load of code into the console.
Does anyone know how to do this?
... and please don't just send me off to yet another 10 hour adventure. If you have any idea how to code it please share the code!