Please help with Run Functional Tests using a Headless Browser II" Challenge

Hi, I’m struggling with the “Quality Assurance and Testing with Chai - Run Functional Tests using a Headless Browser II” challenge. My code seems ok so far, but in order to pass, I need to write an assertion that expects ‘failed’ to equal ‘passed’:

// running tests

expected ‘failed’ to equal ‘passed’

// tests completed

How would I do this?
This is my glitch code.
This is the code that I have written:

                
       chai.request(server)
          .put('/travellers')
          .send({surname: "Vespucci"})
          .end(function(err, res){

        // fill the form, and submit.
        // assert that status is OK 200
        browser.assert.success(res.status, 200);       
        // assert that the text inside the element 'span#name' is 'Amerigo'
        browser.assert.text('span#name', 'Amerigo');
        // assert that the text inside the element 'span#surname' is 'Vespucci'
        browser.assert.text('span#surname', 'Vespucci');       
        // assert that the element(s) 'span#dates' exist and their count is 1
        browser.assert.element('span#dates', 1);
        assert.fail();
        done();
      
      });
    });```

![Capture|608x500](upload://w2X4BUDkbJ3Le2fmXrVUT0XZcCh.png) 
https://imgur.com/6Hrt8MJ

Anyone please advise how to pass this exercise :slight_smile:

Ok, so apparently this works, I don’t really understand why it does.
Can someone explain this please?

      test('submit "surname" : "Vespucci" - write your e2e test...', function(done) {

        // fill the form, and submit.
        // assert that status is OK 200
        // assert that the text inside the element 'span#name' is 'Amerigo'
        // assert that the text inside the element 'span#surname' is 'Vespucci'
        // assert that the element(s) 'span#dates' exist and their count is 1
        browser
          .fill('surname', 'Vespucci')
          .pressButton('submit', function(){
            browser.assert.success();
            browser.assert.text('span#name', 'Amerigo');
            browser.assert.text('span#surname', 'Vespucci');
            browser.assert.element('span#dates', 1);
          done();
´´´
1 Like

Probably had something to do with it.

assert.fail() throws a failure, so you will always receive a “failed” response if you call that assertion within a test. The output from the test was not asking you to write an assertion that expects “failed” to equal “passed,” it was actually telling you that it expected the result of the entire test to equal "passed’.

1 Like

It worked but don’t know why. I had correct code without assert.fail() but it didn’t worked. Then I copied your code and it worked. Also in the previous challenge, I noticed that code only worked when I used single quotes for arguments not with the double quotes