38

I've seen in lot of job advertisements, companies asking for JavaScript knowledge for QA. So my questions are:

  1. What is the use of JavaScript for QA?
  2. If JavaScript is used for testing, what kind of things are tested using JavaScript?
17
  • 7
    It is not obvious if your question is focused only on developers of automated UI tests for web based applications, or you are interested also with skills for manual testers who test web apps (and might build tools to automate some parts of testing, but not fully automated tests), and/or non-web-based applications. In each niche, different skills are needed. Apr 10, 2018 at 14:59
  • 4
    @PeterMasiar Joe isn't asking for advice on what will be most profitable to spend his time on, Joe is asking why these companies might be looking for QA people with javascript knowledge.. It seems you are asking him to answer his own question by listing the purposes js might be used.
    – Mr.Mindor
    Apr 10, 2018 at 18:31
  • 4
    Dear future reader: as you can see, 80% of readers assume that "QA" == "developer of automated UI tests for a web based app". Which might be correct for 80% of the cases, and these hordes are overpowering more cautions QA users like me, who want to add some nuance as found in real life. Provided answers are not wrong, they just assume there is no QA jobs except UI tests for web apps (and yes, those jobs would use JS/protractor etc, as I mention in my answer). Apr 10, 2018 at 18:57
  • 5
    @PeterMasiar I don't think any of the answers are necessarily assuming that. They are just answering the question as posed... Q:"Why might company be asking for javascript?" A: "The company might use javascript for X, Y, or Z." I don't see any answers that say "javascript is only used for x, y or z." Nobody is assuming other types of QA jobs don't exist, but the QA jobs this question asks about apparently use js for something. If they didn't use it, it quite likely wouldn't be listed as a requirement.
    – Mr.Mindor
    Apr 10, 2018 at 19:14
  • 4
    @PeterMasiar I'm not talking about automation. I'm talking about using a website, pressing F12, and going to town.
    – corsiKa
    Apr 11, 2018 at 16:51

11 Answers 11

14

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

  • UI tests (in JS) should be only a very small part of your overall test (about 4%),
  • about 16% test should be for the API (written in JS, other scripting language like Python, or possibly even in a core app language), and
  • 80% unit tests (written in the web application's core language, which in most cases is NOT JS).

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:

  • new language, designed for small code snippets by inexperienced programmers, used way beyond it's original scope, and full of quirks and traps. Even according to experts who like JS there are problematic features of JavaScript that are not easily avoided - and you "must be aware of these things and be prepared to cope".
  • new IDE (seems that everyone writes JS tests in Visual Studio Code), where everything is configured by JavaScript literals
  • new toolchanin (node.js) which is also written in JS. Good example of dogfooding, but it requires the total commitment.
  • language itself is changing, abandoning the "awful" parts mentioning above (ECMAScript versions, "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.

19
  • 5
    How does your experience/opinion that Python and SQL are better tools for a QA engineer to have than javascript help to answer the question of "Why would companies list javascript as a requirement for a QA engineer?"
    – Mr.Mindor
    Apr 10, 2018 at 19:00
  • 4
    ...In response to the first question it may be reasonable to suggest other things might help QA peeps more in general, but in response to the second question, that other languages are used for other things is irrelevant. They are not asking what might Python be used for or SQL.
    – Mr.Mindor
    Apr 10, 2018 at 19:27
  • 5
    I've read it several times. I always reread at least once before asking for clarification. It is clear you are reading a lot more into the question than I am. It is like if someone asked "Why do car makers paint cars?" and you answered "they paint cars to prevent rust, but not all factory workers work on painting cars, some put together the seats, and others do wiring so knowing how to paint cars might not be the most important thing for an autoworker."
    – Mr.Mindor
    Apr 10, 2018 at 19:49
  • 4
    @PeterMasiar Using Javascript for testing is not a fad by any stretch of the imagination. I have written unit, integration, and end to end tests for several different companies at this point. All using Javascript. While I will agree that automated UI tests using JS may be inherently flaky, I would also argue that those same tests would be inherently flaky no matter what language or platform you are using. That being said, there is nothing unstable about writing unit or integration tests for Angular or React projects using Javascript. If done correctly, they are reliable 100% of the time. Apr 10, 2018 at 21:47
  • 1
    It, depends, as always. Python is easiest to start with and useful beyond UI (it is great for random file manipulation or as script/bash replacement). But if you already know JavaScript, or expect to do a lot of front-end programming later, JS rules front-end development. I did all my UI testing (and also API testing) using Python (with Selenium for UI browser automation), but front-end developers did unit tests for front-end code (Angular) in JS Apr 2, 2020 at 19:38
51

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:

  • understand how dynamic and asynchronous UI is built
  • troubleshoot different problematic cases when something is working in the different way than you expect and filter out the cases which are NaB
  • catch the potential defects when everything is working fine but there are some error messages in JS console
  • help your dev team to resolve the root-causes of your defects and gain your professional reputation
  • inject some JS which would help you to test the app (e.g. putting some valuable info on the current client state to the browser's status bar or alert )
  • test for vulnerabilities like XSS
  • ...and many other funny things...
16
  • 6
    Software QA is not limited to web development. It's pretty much useless to learn JavaScript if the product doesn't rely on web technologies.
    – Florent B.
    Apr 10, 2018 at 14:08
  • 12
    Sorry guys I cant understand your point. I totally agree that JS is useful for web in general. I just answered the question that had been stated in the form it had been stated. Not about SQL and not about Python, but about Javascript.
    – Alexey R.
    Apr 10, 2018 at 15:01
  • 15
    @PeterMasiar: The question is framed in the context of job advertisements that ask for JS expertise. Presumably, the companies which advertise in such a way use JavaScript for something. Or, maybe, whoever wrote the job ad has no clue. Apr 10, 2018 at 15:14
  • 11
    I'm really confused by the majority of the discussion on this answer. The question was specifically about why a QA Engineer would need to know Javascript. Alexey answered the question perfectly. Apr 10, 2018 at 15:41
  • 8
    @Florent B. I wholly disagree. The question was specifically about why employers would be looking for a QA Engineer with JS knowledge. The answer addresses the question as it was asked. It doesn't assume or suggest anything. Apr 10, 2018 at 17:22
13

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.

11

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.

3
  • But id OP will never write a line in JS, would not be time spend on learning JS better spent on something else, which OP would use? Life is short and time is precious, focus on learning useful things. Maybe learning SQL, or Python for text parsing/file manipulation, mastering Jenkins or Elastic Search would be time spend better than in JS? Apr 10, 2018 at 17:36
  • 9
    Getting a law degree might be more lucrative too, but the Op asked about JavaScript.
    – user246
    Apr 11, 2018 at 3:21
  • @user246 - In the long term, learning more can be better, provided you can remember things well. Say that a person wants to automate testing of both front end and back end code, i.e. not just UI. The person needs to pick up one language in the current year. Then which one could be recommended to him ?
    – MasterJoe
    Mar 24, 2020 at 17:54
6

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:

  • perform only manual testing
  • perform only automated testing
  • perform manual and automated testing

Why would programming help a manual QA Engineer:

  • will learn how to build things -> will know better how to break things (similar to security testing field)
  • will logically learn how things work and why they work in a specific way -> create more complex and/or efficient test scenarios
  • will learn how to debug correctly and find the root cause of a issue -> very helpful when reporting an issue, and can save a lot of time on developer's side
  • will learn how to solve problems, not only to find them -> when reporting an issue, expected results will be more accurate and can even open new ideas or functionalities

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.

5

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.

2

What is the use of JavaScript for QA?

  • Writing automated tests, for example with Webdriver.js
  • Understanding how modern web applications work

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.

3
  • Say that I want to automate UI & backend tests. I need to write a lot of "non-ui" code to support my tests, such as read/write to database, file parsing, message queue processing etc. I have to pick one language to learn in the current year so that I can automate both ui & backend testing. Then, which language would you recommend to me (as top priority)? I could learn other languages later.
    – MasterJoe
    Mar 24, 2020 at 18:24
  • 1
    @MasterJoe2 It depends greatly on the application. I would use the same language as the application, because you can re-use code for calling API's and databases. Also the developers can help you more easily. If I was solo and the language of the application would be something obscure like Scala I would probably pick a dynamic typed language. I would pick Python, because I want to use it more. So it is also personal preference, if you like statically typed languages pick that. I would at-least pick a top 5 language (pypl.github.io/PYPL.html), because it easier to scale with more people. Mar 25, 2020 at 10:26
  • 1
    @MasterJoe2 All top language support your use-case, maybe also consider future employablity. So scan job-listings and what is in high demand in your area. Or context, if you want todo more data-science pick Python, if you want todo more webdevelopment pick JavaScript. If you want togo into corporate development pick Java/C# Mar 25, 2020 at 10:29
2

// 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.

1
2

In the era of nodeJS based leading automation frameworks:

  • Playwright
  • Puppeteer
  • Cypress
  • Protractor
  • testCafe
  • Nightwatch
  • WebdriverIO
  • webdriverJS and many more

    learning JavaScript is NOT just useful but mandatory for QA engineers.

1
  • 1
    JS is the language of frontend, so if you want to test frontends, you need to know some JS.
    – pavelsaman
    Nov 22, 2020 at 16:34
1

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:

  1. 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.

  2. 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.

  1. As a manual tester you can easily test the application by putting alert, verification error on the browser itself.

  2. 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:

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!!

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.