Guest User

Untitled

a guest
May 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. My main goal is to have tests fail as soon as things go wrong rather than the usual thing where failures in browser testing of single page web apps tend to manifest as timeouts.
  2.  
  3. Second goal is to have really useful errors so you don't have to try and infer what went wrong quite so often.
  4.  
  5. In terms of style I want to be able to use async/await, my favourite assertion library and a normal test runner. Basically not nightwatch, not anything selenium/chromedriver related. Also a knowable, sane system.
  6.  
  7. It is a pity that puppeteer would basically lock you into chrome, but I've already seen a Firefox headless wrapper that mimicks the API. Maybe Microsoft will catch on and do the same? I feel strongly that Selenium/Webdriver is a dead end.
  8.  
  9. --
  10.  
  11. I think the first killer feature here is that each page gets a Promise that will reject the moment there's any error in the page. Then I wrap every puppeteer page method with Promise.race() so it will reject if there's a page error or resolve if the operation succeeds. Whichever comes first. No more timing out waiting for something while there's actually an error in the browser's console that you can't see. It actually rethrows the browser error right inside your test.
  12.  
  13. Then waitForAny wraps puppeteer's waitFor. You can pass it good CSS selectors and bad selectors and it waits for both. It throws if a bad selector was found. You can use this to wait for either the successful state to appear OR an error. Like a confirmation dialog but also an error banner or dialog. Whichever comes first. So unlike some other browser testing frameworks you don't have to wait for it to time out because the success element never appears.
  14.  
  15. That's it for now. I have lots more ideas, but these are the ones that are already implemented and working.
Add Comment
Please, Sign In to add comment