Zombie.js - Check if Checkbox is selected and How to know where exactly test case is getting failed

322 Views Asked by At

I am trying to achieve functional testing on a HTML page using Zombie.js[headless browser] and Mocha[testing framework]. Below is my HTML page

<div id="toggle" style="display:none">Hello There
            <ul>
                <li>
                    <label>Bike</label>
                    <form action="">
                        <input type="checkbox" 
                         id="bike" name="vehicle" 
                         value="Bike" checked="true">
                         I have a bike<br>                        
                    </form>
                </li>

Using Zombie.js and mocha, How can i make test that Checkbox is selected or not. Also while running test cases, how will i get to know which function/line is wrong or getting failed.

1

There are 1 best solutions below

0
Amit Kumar Gupta On

I just tried it for my application fast-xml-parser using jasmine. (You can see the tests for more detail)

const Browser = require('zombie');//npm
//include zombie js in your project otherwise
:
//Create the instance before you use
browser = new Browser({site: 'http://localhost:'+port});
browser.assert.input('#textNodeConversion', true); //selected