I am trying to using Cypress (which contains mocha, plus I am using mocha-chai) to check for a series of words NOT included in a phrase. That is because for example, I have three <div>s and I want to check
- that words in div1 are present in div1 but not in div2 and div3;
- that words in div2 are present in div2 but not in div1 and div3;
- that words in div3 are present in div3 but not in div1 and div2.
To do that I'm using .contain and .not.contain but unluckily they find some substrings:
if I have
// div1
<div>
...
The perfect professionist for you
</div>
// div2
<div>
...
Good professionists are ready here
</div>
I do
expect(div1).to.contain('professionist') // true
expext(div1).to.not.contain('professionists') // true
this is fine, but
expect(div2).to.contain('professionists') // true
expect(div2).to.not.contain('professionist') // false!
will fail.
Is there a way using cypress, mocha or anything similar to do a check on entire word but not substring?
