Context
Me and my friends been doing functional testing on our rather large single-page app, using Mocha and JQuery. JQuery is used to drive the system under test (SUT), usually started in an IFrame. JQuery is also used to verify that the application behaves as expected. For instance, in a todo-application, you might
S("#addTodo").click()
expect(S("#tasks").length).to.equal(1)
Here S is a helper function that delegates to the JQuery instance in the SUT window. So the basic pattern is that you perform certain operations on the SUT and then verify that the application ends up in the expected end-state. In mocha, you might do this like
describe("Add todo button", function() {
before(function() {
S("#addTodo").click()
})
it("Adds todo", function() {
expect(S("#todos").length).to.equal(1)
})
})
If the application is synchronous this works just fine.
Problem
You might have guessed this. The minute you add your first asynchronous thing in the application, you enter the world of uncertain test results. That is, if your tests assume that after doing X, the application goes from state A to B. To get past this, you may use asynchronous functions in your
before
blocks. Likebefore(function(done) {
wait.until(function() { return S("#todos").length == 2}, done)
})
This will fix a single test case. Everytime you find that some test is unreliable, you add some kind of an ad-hoc asynchoronous wait. Now step to a situation where you have a hundred tests and you change your application so that something that used to be synchronous is now asynchronous. You'll get some failing tests. You may get tests that fail on some browsers and only sometimes. Horror!
Adding async waits to individual test setup steps doesn't scale. Been there, done that.
Solution
I strongly believe that we need a more systematic solution here. The developer shouldn't need to consider asyncronicity at each test step.
Why not go for a solution where after each
before
block and before each it
, there should be an implicit async wait that would ensure that before the test proceeds, the framework ensures that all AJAX calls, animations, transitions, page loads and whatnot have finished.
Is this hard? Shouldn't be. Just monkey-patch
before
and it
to include these steps. Gonna try this and write more afterwards. What do you think?
Hi,
ReplyDeleteYou may be interested in https://github.com/martin-g/gym.js
I've blogged about it at http://wicketinaction.com/2012/11/javascript-based-functional-testing/
More real life usage at https://github.com/apache/wicket/tree/master/wicket-examples/src/main/webapp/js-test
Superb blog I visit this blog it's really awesome. The important thing is that in this blog content written clearly and understandable. The content of information is very informative.
ReplyDeleteOracle Fusion HCM Online Training
Oracle Fusion SCM Online Training
Oracle Fusion Financials Online Training
Big Data and Hadoop Training In Hyderabad
oracle fusion financials classroom training
Workday HCM Online Training
Oracle Fusion HCM Classroom Training
Workday HCM Online Training
Nice Post
ReplyDelete"Pressure Vessel Design Course is one of the courses offered by Sanjary Academy in Hyderabad. We have offer professional
Engineering Course like Piping Design Course,QA / QC Course,document Controller course,pressure Vessel Design Course,
Welding Inspector Course, Quality Management Course, #Safety officer course."
Document Controller course
Pressure Vessel Design Course
Welding Inspector Course
Quality Management Course
Quality Management Course in india
Safety officer course
Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care
ReplyDeletehttp://traininginmedavakkam.in/training-courses/ccna-training-in-medavakkam/
http://traininginmedavakkam.in/training-courses/rpa-training-in-medavakkam/
http://traininginmedavakkam.in/training-courses/uipath-training-in-medavakkam/
http://traininginmedavakkam.in/training-courses/automation-anywhere-training-in-medavakkam/
http://traininginmedavakkam.in/training-courses/msazure-training-in-medavakkam/
It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
ReplyDeletehttp://trainingincoimbatore.in/catia-training-in-coimbatore.html
http://trainingincoimbatore.in/networking-training-in-coimbatore.html
http://trainingincoimbatore.in/pmp-training-in-coimbatore.html
http://trainingincoimbatore.in/primavera-training-in-coimbatore.html
http://trainingincoimbatore.in/digital-marketing-training-in-coimbatore.html
http://trainingincoimbatore.in/tally-training-in-coimbatore.html
I enjoyed your blog Thanks for sharing such an informative post. We are also providing the best services click on below links to visit our website.
ReplyDeletedigital marketing company in nagercoil
digital marketing services in nagercoil
digital marketing agency in nagercoil
best marketing services in nagercoil
SEO company in nagercoil
SEO services in nagercoil
social media marketing in nagercoil
social media company in nagercoil
PPC services in nagercoil
digital marketing company in velachery
digital marketing company in velachery
digital marketing services in velachery
digital marketing agency in velachery
SEO company in velachery
SEO services in velachery
social media marketing in velachery
social media company in velachery
PPC services in velachery
online advertisement services in velachery
online advertisement services in nagercoil
web design company in nagercoil
web development company in nagercoil
website design company in nagercoil
website development company in nagercoil
web designing company in nagercoil
website designing company in nagercoil
best web design company in nagercoil
web design company in velachery
web development company in velachery
website design company in velachery
website development company in velachery
web designing company in velachery
website designing company in velachery
best web design company in velachery
Thanks for Sharing - ( Groarz branding solutions )
I enjoyed your blog Thanks for sharing such an informative post. We are also providing the best services click on below links to visit our website.
ReplyDeleteOracle Fusion HCM Training
Workday Training
Okta Training
Palo Alto Training
Adobe Analytics Training
Amazing or I can say this is a remarkable article.
ReplyDeleteBA 1st Year Admit Card 2022
BA 2nd Year Admit Card 2022
BA 3rd Year Admit Card 2022
This post is so useful and informative.Keep updating with more information.....
ReplyDeletePython Training In Bangalore
Python Course In Bangalore
what a blog on Microsoft Azura. Detailed discussion can be seen. Keep it up.
ReplyDeleteWe also provide various professional software courses.
https//.sclinbio.com.
thanks for valuable info
ReplyDeletegcp training
"I found this article to be extremely helpful and well-structured. Thank you!"
ReplyDeleteModular Kitchen & Wardrobe in Raipur