Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Quality Assurance Intermediate Selenium WebDriver Use Selenium with Testing Frameworks The async and await Keywords

Timeout Promise Error for async/await section

I have copied the code from the 'The async and await Keywords' teacher's notes, but when I run the mocha command, I'm getting this error: "Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves." I'm using Windows 10.

I did some searching and found similar questions on stackoverflow and the github mocha page, but I haven't found a fix yet for this scenario.

Has anyone else run across this same issue? Thank you.

3 Answers

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

Out of curiosity, are you using the Firefox ("gecko") driver? On my Mac I found this was a problem with Firefox but not with Chrome.

Mocha tests have a default timeout of 2000 milliseconds. (This is separate from the WebDriver timeout.) Try setting it to 3000 or 4000 and see if that helps. https://mochajs.org/#timeouts

Thanks for the reply, Jay McGavren. I'm testing with Chrome and Firefox.

I added 'this.timeout(3000);' inside each it statement and the tests for Chrome are passing now, but FF is failing. It seems like adding that to each it statement is overkill, so I'll keep looking at questions as they are asked in this class to see if there are other updates. I noticed after I posted my question that Jonathan Grieve asked a similar question, so I'll check his responses too since we helped each other with some issues in the other Selenium course.

after describe I added this.timeout(6000); this worked for me. Now all the test are passing!