Quality Assurance and Testing with Chai - Simulate Actions Using a Headless Browser

Tell us what’s happening:

“done” is a callback function so it needs parentheses

Challenge Information:

Quality Assurance and Testing with Chai - Simulate Actions Using a Headless Browser

Except it doesn’t. You see done is being passed as an argument to browser.visit.

Here’s some example code from First-class Function - MDN Web Docs Glossary: Definitions of Web-related terms | MDN to help illustrate my point .

function sayHello() {
  return "Hello, ";
}
function greeting(helloMessage, name) {
  console.log(helloMessage() + name);
}

You see the variable in the greeting function is getting called as a function. That’s because JavaScript expects the variable to be one. If we call that function when it gets passed in; that variable won’t be a function and the code won’t work.

Here’s the correct way to call greeting.

// Pass `sayHello` as an argument to `greeting` function
greeting(sayHello, "JavaScript!");
// Hello, JavaScript!

Does this make sense? Let me know if I can help explain things further. As is, I think we are going to explain callback function properly at some point.