Home > database >  Testcafe falsely asserting false
Testcafe falsely asserting false

Time:12-08

Testcafe is yielding the following result

) AssertionError: expected 'Field \'HANDLING POINT\' is required.' to deeply equal 'Field \'HANDLING POINT\' is required.'

        expected - actual

      -Field 'HANDLING POINT' is required.
       Field 'HANDLING POINT' is required.

from the below code

await t.expect(Selector(".jsError").child().child().innerText).eql("Field 'HANDLING POINT' is required.");

I'm quite confused as I've tried everything I can thing of and yet the same code works fine for different text.

This is the html I am testing agaisnt. I I test for the shift field message, all is well

<span ><ul><li>Field 'HANDLING&nbsp;POINT' is required.</li><li>Field 'SHIFT' is required.</li></ul></span>

CodePudding user response:

A Non-Breaking Space, represented by &nbsp; in HTML, is a different character from a regular space. You can use the escape sequence \xA0 to represent it in the JavaScript string literal you're comparing against.

  • Related