[Quality Assurance and Testing with Chai] Example functional test failing
See original GitHub issueDescribe your problem and - if possible - how to reproduce it
When submitting my solution for Run Functional Tests using a Headless Browser all tests are passing except the first one - All tests should pass After inspecting the glitch logs I found out that the example test is also failing:
1) Functional Tests
e2e Testing with Zombie.js
"Famous Italian Explorers" form
#example - submit the input "surname" : "Polo":
TypeError: browser.fill(...).pressButton is not a function
at Context.<anonymous> (tests/2_functional-tests.js:217:12)
This is the test function from the example:
test('#example - submit the input "surname" : "Polo"', function(done) {
browser
.fill('surname', 'Polo')
.pressButton('submit', function(){
// pressButton is ## Async ##.
// It waits for the ajax call to complete...
// assert that status is OK 200
browser.assert.success();
// assert that the text inside the element 'span#name' is 'Marco'
browser.assert.text('span#name', 'Marco');
// assert that the text inside the element 'span#surname' is 'Polo'
browser.assert.text('span#surname', 'Polo');
// assert that the element(s) 'span#dates' exist and their count is 1
browser.assert.element('span#dates', 1);
done(); // It's an async test, so we have to call 'done()''
});
});
And this is my solution:
test('submit "surname" : "Colombo" - write your e2e test...', function(done) {
// fill the form...
// then submit it pressing 'submit' button.
//
// in the callback...
// assert that status is OK 200
// assert that the text inside the element 'span#name' is 'Cristoforo'
// assert that the text inside the element 'span#surname' is 'Colombo'
// assert that the element(s) 'span#dates' exist and their count is 1
browser
.fill('surname', 'Colombo')
.pressButton('submit', function(){
/** YOUR TESTS HERE, Don't forget to remove assert.fail() **/
// assert that status is OK 200
browser.assert.success();
// assert that the text inside the element 'span#name' is 'Cristoforo'
browser.assert.text('span#name', 'Cristoforo');
// assert that the text inside the element 'span#surname' is 'Colombo'
browser.assert.text('span#surname', 'Colombo');
// assert that the element(s) 'span#dates' exist and their count is 1
browser.assert.element('span#dates', 1);
done(); // It's an async test, so we have to call 'done()''
});
});
Add a Link to the page with the problem
Quality Assurance and Testing with Chai - Run Functional Tests using a Headless Browser
Tell us about your browser and operating system
- Browser Name: Chrome
- Browser Version: 67.0.3396.99 (Official Build) (64-bit)
- Operating System: Windows 10
If possible, add a screenshot here
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Quality Assurance and Testing with Chai | FreeCodeCamp
I go through the quality assurance and testing with Chai portion of FreeCodeCamp. The beginning tests were super easy, but the last four ......
Read more >Run Functional Tests Using a Headless Browser I &II -- One ...
Quality Assurance and Testing with Chai - Run Functional Tests Using a Headless Browser I &II -- One of the tests keeps failing....
Read more >Testing with Mocha and Chai
Let's learn about unit testing our code using Mocha, which is a light-weight Node.js test framework, and Chai, which is a TDD assertion ......
Read more >Testing Node.js Code with Mocha and Chai
In this guide - learn the basics of testing in JavaScript with Mocha and Chai - focusing on Unit Testing and creating test...
Read more >How to Write Simple Unit Tests in JavaScript with Mocha ...
Unit testing is the most foundational level of software testing. In this level of testing, individual functionality, modules, procedures or even ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I found the problem. The test in the challenge is testing for a single quotation.
Here
'\'span#name\''
and here'\'Cristoforo\''
I just replace the double quotations for single quotations and the local and challenge tests pass.
Should be use assert.match() instead of assert.equal() in the challenge test? Maybe replace double quotation for a single in assertion-analyser.js??
on version 6.2.1 .fill method doesnt return the Browser object anymore soo its not possible to do method chain
and .element method only check if the element exist to check for “count” element, there are another method named elements (plural) which accept a count parameter