I've seen in lot of job advertisements, companies asking for JavaScript knowledge for QA. So my questions are:
- What is the use of JavaScript for QA?
- If JavaScript is used for testing, what kind of things are tested using JavaScript?
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communityI've seen in lot of job advertisements, companies asking for JavaScript knowledge for QA. So my questions are:
To answer your questions:
1: What is the use of JavaScript for QA?
UI Testing of web pages, when the UI is written using JS-based UI front-end frameworks like Angular and friends as is the current standard (there are many: Short and Brutal Lifecycle of JavaScript Frameworks)
2: If JavaScript is used for testing, what kind of things are tested using JavaScript?
The front-end of a web-based app. And even for web-based apps, whose UI is written using one of the JS frameworks, JS in not the only (and often not the best) language to write tests. And the app backend is most likely written in a different language, not JS.
More detailed answer, to things you haven't asked, but should:
TL;DR: JavaScript is ubiquitous (especially for the frond-end), is here to stay for a long time, and good to know if you like it, but is not strictly necessary (beyond learning the trivial basics), because other languages (like Python) are a better fit IMHO (give you a better return on your time invested in mastering them) for most of use cases beyond UI (like API testing, custom DevOps tools etc).
Not all testers are writing automated tests for a living.
A manual tester has little or no immediate need to learn any programming language. Programming induces specific thinking to a person, so it is beneficial if some manual testers do not think as a programmer would, so they can find bugs which programming-thinking person will miss.
But many learn "some" programming anyway, mhd's answer explains why (even if I disagree that every manual tester needs to learn basic programming).
Learning SQL helps with investigating data in database-related issues. No need to be an expert, being able to grok and tweak SQL queries provided by expert developers is enough.
Learning a simple language like Python allows a tester to write simple tools manipulating data, searching for patterns etc.
Learning JavaScript is a bigger decision. It would be useful ONLY if the tester works/is interested in testing front-end/UI parts of an application written in some JS framework.
Recently we had several questions related to the test pyramid:
Consensus is that
We (in our company) have many UI tests in Python/webdriver, are currently considering transition to JS/protractor, and it is a steep and long learning curve. Because you need to learn:
"use strict;"
, TypeScript).Many of these complications (and strategies to handle them) are important for front-end developers (because they do not have control which variety of JS is installed on users device - and not even which browser version from which vendor, each with own bugs in JS implementation), but they are unnecessary baggage for a QA tester with substantially better control of the environment.
I am not sure if switching to writing UI and API tests in JS is worth the effort. From a test developer's POV, dealing with expected conditions (synchronous) is much easier than asynchronous promises in JS.
So, in my opinion, learning JS might be a valuable addition to an automated tester's skillset (for reasons listed in answer by Alexey R., but also might not be necessary if the automated tester is expert in another language like Python, and furthermore tests for the middle level of the test pyramid (API/services level) can be more productively written and maintained in Python than in JS. For UI tests, JS is almost required, for the API/services layer, not so much.
We are currently considering writing some basic UI tests in JS, but maintaining another set of UI tests in Python, which we plan to use also for API/services tests and which are in our core app language (Python, as are most of the tools for DevOps). The reason is productivity: our devs are more productive in Python than JS (write more reliable and maintainable code). We have few JS experts but for most other devs, to attain their current Python level competency in JS will take a year or two (or more, as our main app and DevOps language remains Python). This might change as we gain more experience in JS for production-level deployment, and JS is becoming more strict and reliable ("use strict;" TypeScript etc).
Edit, Dec 2018:
(1) As API testing is becoming more important (for good reasons), another layer of the problem area is solidifying: JS is great for GUI tools for manual API testing like Postman and Insomnia (which uses JS literals), but those GUI tools suck as runners of regression test batches. Such regression are much better handled by unit test runners.
(2) If a GUI tool promotes "variables and templates" as cool features, you know they want to have REAL programming language (Greenspun's tenth rule: Any sufficiently complicated program contains a bug-ridden, slow implementation of half of Common Lisp)
(3) JS literals are almost identical to Python literals. Requests is amazing Python library for API testing, and Insomnia generates Python code snippets to be used with requests library, ready for unit tests. So you have flexibility of manual API testing, and flexible language (Python, with REAL variables, templates, files, parsing and everything) for unit tests. And using requests from python interpreter is almost like Insomnia.
(4) API testing allows tester to test less in JS (less GUI-level testing), and more in the backend language. Using Pareto 80/20 rule, instead of 80% unit tests and 20% GUI tests (in JS), we have 80% unit, 16% API (80% remaining 20%), and just 4% in GUI.
/Edit>
But also some of our (backend) Python dev experts are not eager to invest many years of life mastering JS, and might switch jobs to keep improving Python skills instead of being forced too deep into JS.
In my experience, while JS might be an important language for a UI automation tester, Python is a far better language for file manipulation, text parsing and building command-line tools (DevOps tools), has fewer hidden traps than JS, better libraries (with little gems like argparse ) and also is easier to learn as a first language.
So while learning basics of JS is easy and fun, (if you have experts handing the complexities), and you should do it, including learning about the quirks and traps, but mastering JS with all its complexities might not be needed if you are competent QA engineer in other languages.
I think that the strongest argument for learning JavaScript for QA is Appium (for testing apps for iOS and Android, in JS) and how important it is for your career. But for some reason, it was not mentioned in any other answers.
Well, apart from the obvious answer like "QA engineer should learn JavaScript to be able to use TA frameworks which work with JavaScript" I would say that a QA engineer should learn JS because knowing even basic aspects of how JS works or how it is applied to Web development brings you to a new level of defect hunting.
Knowing basics of JS will let you:
One of the reasons would be to write end-to-end automated tests using Protractor. Protractor is an end-to-end test framework for Angular and AngularJS applications, where you write tests in javascript. It is designed to work better with angular applications better than pure Selenium.
Additionally, knowledge of a programming language used in a project may be helpful even for a QA engineer that tests manually.
The more you learn about the technologies your developers use, the better you will be at your job, and the more valuable you will be. In other words, even if you never write a line a JavaScript for your job, you will still be in a better position to test someone else’s JavaScript.
I think the basic question should be "Why a software QA engineer should learn programming".
Which programming language to learn is not important, it can always change. As a QA Engineer, you can work on projects from several platforms (web frontend, web backend, mobile, desktop, IoT devices etc).
A QA Engineer could be required to:
Why would programming help a manual QA Engineer:
Programming is just a part of the QA Engineer role, but in my opinion, an important one. It's also not as complex as a developer's work, so I think that every QA can learn how to program at a basic level and bring more value to the project.
With the popularity of JS Frameworks like Angular
, React
, Nodejs
, there has been a surge in the testing frameworks using JS- be it an E2E framework like Protractor
, Nightwatch
, Cypress
or API testing frameworks like Chakram
etc.
I agree with Peter's answer and I think it puts a lot of valid points.
A frequent argument for the surge of these JS frameworks and need to learn JS is that there are a lot of advantages if your automation framework is developed using the same tech stack that your UI/API uses. There is a good amount of valid points and arguments given in this excellent post.
What is the use of JavaScript for QA?
If JavaScript is used for testing, what kind of things are tested using JavaScript?
Most testings tools are programmable with JavaScript, some examples:
Next to that the Node.JS runtime environment is the fastests growing and largest package registry in the world, with which you can quickly build handy command-line tools, possibly to automate your testing efforts (e.g. data generation or chain stuff).
You can do and build everything with JavaScript, it is becoming the bread and butter of the engineering world.
// The Why
Javascript is gradually becoming the required language for a QA Engineer mainly due to the dominance of its ecosystem in the modern development frameworks and thus in the software development world.
// Front End
Regarding the UI/E2E Testing, the use of Javascript gives you the advantage to better collaborate with the Front End team since you will have JS as a common ground. You will be able to peek and even contribute to their code base in the long run if you wish so (code reviews, unit tests, etc).
// Back End
With the rise of NodeJS Javascript presence in the back-end is increasing, giving you an additional 'hook' to understand it, interact with it, and eventually test it in a more effective way.
// The Value
But besides using a language that's closer to the one used for developing the product-in-test, I believe that -compared to other used languages like Java- Javascript gives you the opportunity to learn & invest time within its ecosystem which is continuously growing & expanding, and make the transition to a 'pure' development job (either front-end or back-end) more smoothly. Even if you never plan to make such transition, it's a strong skill to possess nowadays.
P.S. You can find a neat list with JS automation frameworks & tools here.
webdriverJS and many more
learning JavaScript is NOT just useful but mandatory for QA engineers.
Ok. I will be as honest as possible here.
1. What is the use of javascripts to QA?
Today everyone started learning Automation Started with Java + Selenium as a basic.But then came to realze that certain action on webbrowser can be performed by Javascripts only. So know couple of basic things of javascripts and how to use in open source tools such as selenium,Appium etc.
See if you really go to the basic javascript is the basic browser implementation language so it is good to learn javascript over java.
Use of javascripts to QA:
I think JS would be a great first language, as the basics are fairly simple. There are definitely complex parts to it, but you don't necessarily need those to write automation and best part webased element interaction will be easier to dealt with as most of application these days writtten in Angular 4 and node.js.
Frontend or Backend, though the good news is you can do either of the type by using Javascript as a language of preference..!!
For frontend you can go though the concepts of web element locators, xpaths are the popular ones! i.e if you want to learn only one type of element locator. Then its only up to your JS knowledge to make most use of the features provided by selenium.
As a manual tester you can easily test the application by putting alert, verification error on the browser itself.
Last but not lease it can help you to easily implement Shift left in test cycles.
and so on.
Where you can used javascripts frameworks:
as this is native client language you can design front end, back end automation framework using this. not only that you can scale these framework to do performance, security penetration testing.
You can refer below:
protractor - https://www.protractortest.org/#/infrastructure ( for Front end web based application).
selenium Webdriver with javascripts - https://applitools.com/tutorials/selenium-javascript.html
There are couple of other frameworks i would like to recommend you are Chai and Mocha. I have tried Chai, its pretty fast and popular among JS automation for Mobile/Front end as well..
For backend or rather End to end testing Cypress might be a good choice, it was firstly developed for unit testing by developers but it can be used by testers as well.I have used it for frontend testing and the experience was very good.
Hope it helps!!
As a web application/frontend Tester, you can, apart from many other things already mentioned here, make your work a little bit easier and faster thanks to JS.
Just a few examples.
You might want to find and highlight all pictures with no alt attribute, it's just a few lines of JS in browser console:
// pictures with no alt attribute
for (let i of document.getElementsByTagName('img')) {
if (!i.hasAttribute('alt'))
i.style = i.style + "; border:2px dashed red;";
}
Want to find all input field w/o required attribute?
// inputs w/o required attribute
for (let i of document.getElementsByTagName('input')) {
if (i.hasAttribute('required'))
i.style = i.style + "; border: 2px dashed red;";
else
i.style = i.style + "; border: 2px dashed green;";
}
Same ids could be an accessibility problem, let's highlight such elements:
// highlight elements with same ids
let all = document.getElementsByTagName('*');
let ids = {};
for (let el of all) {
if (el.hasAttribute('id')) {
if (ids[el.id]) {
ids[el.id].push(el);
for (let e of ids[el.id]) {
e.style = e.style + "; border: 2px dashed red;";
}
} else {
ids[el.id] = [];
ids[el.id].push(el);
}
}
}
Placeholders should not be missing, let's find out:
// inputs w/o placeholder attribute
for (let i of document.getElementsByTagName('input')) {
if (!i.hasAttribute('placeholder'))
i.style = i.style + "; border: 2px dashed red;";
else {
if (i.placeholder === "")
i.style = i.style + "; border: 2px dashed red;";
else
i.style = i.style + "; border: 2px dashed green;";
}
}
And so on...
You can also build your own Chrome extensions and streamline your work even more.