<QA Course> what I should do to avoid a test timeout?

Error :

1) Functional Tests with Zombie.js
       "Famous Italian Explorers" form
         Submit the surname "Colombo" in the HTML form:
     Uncaught AssertionError [ERR_ASSERTION]: Expected selector "span#name" to return one or more elements
      at Assert.text (node_modules/zombie/lib/assert.js:182:5)
      at /home/runner/boilerplate-mochachai/tests/2_functional-tests.js:89:21
      at done (node_modules/zombie/lib/eventloop.js:424:9)
      at Timeout.timeout (node_modules/zombie/lib/eventloop.js:436:31)
      at listOnTimeout (node:internal/timers:564:17)
      at process.processTimers (node:internal/timers:507:7)

Situation :
The first test item in this problem, “All tests must succeed.” times out every time and does not pass the test.

The other four tests have already been passed.

What have I tried :

  • Searching in the forum
  • Checking for typos
  • Extending this.timeout
  • Change browsers (Chrome & Edge)

I also tried to output err or res to console in the done method, but nothing was output.

// #5
		test('Submit the surname "Colombo" in the HTML form', function(done) {
			browser.fill('surname', 'Colombo').then(() => {
				browser.pressButton('submit', () => {
					browser.assert.success(); // status: OK 200
					browser.assert.text('span#name', 'Cristoforo');
					browser.assert.text('span#surname', 'Colombo');
					browser.assert.elements('span#dates', 1);
					done((err, res) => err ? console.log(err) : console.log(res));
				});
			});
		});

This led me to believe that the test was not wrong, but rather that it timed out before reaching the test.

references :

test suite:

// Headless browser for testing web pages
const Browser = require('zombie');
Browser.site = 'https://boilerplate-mochachai.so-san.repl.co';

const browser = new Browser();
// Set browser to the route "/"
suiteSetup(done => browser.visit('/', done))

suite('Functional Tests with Zombie.js', function() {
	this.timeout(50000);

	suite('Headless browser', function() {
		test('should have a working "site" property', function() {
			assert.isNotNull(browser.site);
		});
	});

	suite('"Famous Italian Explorers" form', function() {
		// #5
		test('Submit the surname "Colombo" in the HTML form', function(done) {
			browser.fill('surname', 'Colombo').then(() => {
				browser.pressButton('submit', () => {
					browser.assert.success(); // status: OK 200
					browser.assert.text('span#name', 'Cristoforo');
					browser.assert.text('span#surname', 'Colombo');
					browser.assert.elements('span#dates', 1);
					done();
				});
			});
		});
		// #6
		test('Submit the surname "Vespucci" in the HTML form', function(done) {
			assert.fail()
			done()
		});
	});
});

Yes, I had MANY problems with tests timing out in the QA Certificate. I have two solutions.

  1. Follow this guide to run the lessons locally: How to Run the freeCodeCamp Backend Challenges Locally I tried to avoid doing this, but it became necessary eventually because all my tests kept timing out once I got to the ZombieJS section.

  2. You can try timing your submission. I’d often hit “Run” in Replit, wait for the server to start, then immediately submit it on the freeCodeCamp page. That usually worked.

2 Likes

Thank you for your suggestion.

As for solution “2.”, I have tried it many times in my previous challenges and it worked well until the last challenge.

However, this challenge was a time when the solution “2.” did not work and I was in trouble.

So, I would like to try the “1.” solution.
Thanks @aburke1234 !

If anyone knows of any other effective solutions, I would be glad to hear your suggestions.

I ran the test locally as described in Solution “1.” and was able to run the test successfully. Thanks @aburke1234 !

However, there were a few things to note, so I’ll leave them here for future users who may have the same problem.

  • First of all, you need to have node.js installed on your PC (this will also install npm).
    https://nodejs.org/
  • In the code, you need to set Browser.site='0.0.0.0:3000'. (Reading the curriculum, it may seem that setting Browser.site='http://localhost:3000' is sufficient, but this did not work.)

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.