I have this button to test in a file test.html :
<button id="ref_button" type="submit" [disabled]="editForm.form.invalid || isSaving" class="btn btn-primary">
I am using protractor, cucumber, and chai dom to test if this button is disabled when the form data are invalid, so I check its attribute disabled like this:
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const chai = require('chai');
const expect = chai.expect;
const should = chai.should();
chai.use(require('chai-dom'));
//In given when then step definitions I run teh app, login, go to the form and fill the form with valid data
....
When('I put a valid name',{timeout: 90 * 1000}, function(callback) {
element(by.css("*[id='field_nombre']")).click();
element(by.css("*[id='field_nombre']")).sendKeys('').then(callback);
});
Then('The button Save should be enabled', function() {
JSDOM.fromFile("test.html").then(dom => {
dom.window.document.getElementById("ref_button").should.not.have.attr("[disabled]");
});
Is this a chai-dom issue, or something I implement the wrong way and maybe it doesnt make take the form status valid or invalid?
Aucun commentaire:
Enregistrer un commentaire