Skip to contentমূল লেখায় যান

Step 03 · SDET roadmapধাপ 03 · SDET roadmap

JavaScript for Testers

This page covers the part of JavaScript that a tester uses every day: values, functions, arrays, JSON, async code, and errors. It ends with a small script that you run with Node.js and change yourself.

6 min read6 মিনিটে পড়া যায় · 7 sections7টি সেকশন · 16 sources16টি সোর্স · updated Nov 2026আপডেট: Nov 2026

await pauses, then continuesawait থামায়, তারপর এগোয়

Follow one async call: the promise is pending, then fulfilled or rejected. Then forget await and see what the test holds.একটা async কল অনুসরণ করুন: promise প্রথমে pending, তারপর fulfilled বা rejected। তারপর await বাদ দিন আর দেখুন টেস্টের হাতে কী থাকে।

2 min2 মিনিট7 steps7টি ধাপ
  • Promiseপ্রমিস–
  • Test holdsটেস্টের হাতে–
  • Blocks runচলা ব্লক0 / 3
callকলyour testআপনার টেস্টcalls getEcho('sdet')getEcho('sdet') ডাকেgetEcho()getEcho()async functionasync ফাংশনAPIAPIpostman-echopostman-echotrytrycatchcatchfinallyfinally

You’ll learnআপনি শিখবেন

  • An async function returns a promiseasync ফাংশন একটা promise ফেরত দেয়✓
  • A promise starts pendingpromise শুরুতে pending থাকে
  • What await waits forawait কীসের জন্য অপেক্ষা করে
  • When catch and finally runcatch আর finally কখন চলে
  • Why a missing await gives a promiseawait বাদ গেলে কেন promise মেলে

What it is

JavaScript is a lightweight interpreted (or just-in-time compiled) programming language with first-class functions Source 1সোর্স 1. It is best known as the language of web pages, but it also runs outside the browser, for example in Node.js Source 1সোর্স 1.

Node.js is an open-source, cross-platform JavaScript runtime. It runs V8, the JavaScript engine of Google Chrome, outside the browser Source 2সোর্স 2. Its standard library has asynchronous input and output, so code does not block while it waits Source 2সোর্স 2.

A tester meets JavaScript in the test tools. Postman tests are written in JavaScript Source 15সোর্স 15. Playwright tests are written in TypeScript or JavaScript Source 16সোর্স 16. The next pages build on this one: TypeScript for Testers, API Testing with Postman, and UI Automation with Playwright.

সহজ English

JavaScript is a lightweight programming language Source 1সোর্স 1. People know it from web pages, but it also runs outside the browser, for example in Node.js Source 1সোর্স 1.

Node.js runs JavaScript outside the browser, with the same engine that Google Chrome uses Source 2সোর্স 2. Its standard library does input and output asynchronously, so your code does not get stuck while it waits Source 2সোর্স 2.

A tester meets JavaScript in the test tools. You write Postman tests in JavaScript Source 15সোর্স 15, and Playwright tests in TypeScript or JavaScript Source 16সোর্স 16. The next pages build on this one: TypeScript for Testers, API Testing with Postman, and UI Automation with Playwright.

বাংলা ব্যাখ্যা

JavaScript হলো first-class function-সহ একটা হালকা, interpreted (বা just-in-time compiled) programming language Source 1সোর্স 1। এটা web page-এর language হিসেবে সবচেয়ে পরিচিত, কিন্তু browser-এর বাইরেও চলে, যেমন Node.js-এ Source 1সোর্স 1।

Node.js একটা open-source, cross-platform JavaScript runtime। এটা Google Chrome-এর JavaScript engine V8-কে browser-এর বাইরে চালায় Source 2সোর্স 2। এর standard library-তে asynchronous input/output আছে, তাই অপেক্ষার সময় কোড আটকে থাকে না Source 2সোর্স 2।

একজন টেস্টার টেস্ট টুলের ভেতরেই JavaScript পান। Postman-এর টেস্ট JavaScript-এ লেখা হয় Source 15সোর্স 15। Playwright-এর টেস্ট লেখা হয় TypeScript বা JavaScript-এ Source 16সোর্স 16। পরের পেজগুলো এই পেজের ওপর দাঁড়ানো: TypeScript for Testers, API Testing with Postman আর UI Automation with Playwright।

How it works

সহজ English

বাংলা ব্যাখ্যা

Try it

You need Node.js. Save this as users.mjs and run node users.mjs. The .mjs extension makes the file an ES module Source 12সোর্স 12, so await works at its top level Source 9সোর্স 9. Node.js has a browser-compatible fetch() Source 13সোর্স 13, which the script uses to call the Postman Echo service.

const users = [
  { name: 'Asha', role: 'tester', active: true },
  { name: 'Rafi', role: 'developer', active: true },
  { name: 'Mina', role: 'tester', active: false },
];

const activeTesters = users
  .filter((user) => user.active && user.role === 'tester')
  .map((user) => user.name);
console.log(activeTesters); // [ 'Asha' ]

const firstDeveloper = users.find((user) => user.role === 'developer');
console.log(firstDeveloper.name); // Rafi

const text = JSON.stringify({ course: 'sdet', step: 3 });
console.log(JSON.parse(text).step === 3); // true

async function getEcho(course) {
  try {
    const response = await fetch(`https://postman-echo.com/get?course=${course}`);
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    const body = await response.json();
    return body.args.course;
  } catch (error) {
    console.error('Request failed:', error.message);
    throw error;
  }
}

console.log(await getEcho('sdet')); // sdet

The output:

[ 'Asha' ]
Rafi
true
sdet

Now change Mina to active: true and run it again. The first line becomes [ 'Asha', 'Mina' ]. Predict the output before each run: it is a quick way to learn the array methods.

সহজ English

You need Node.js. Save this as users.mjs and run node users.mjs. The .mjs ending makes it an ES module Source 12সোর্স 12, so await works at the top Source 9সোর্স 9. Node.js has a fetch() that works like the browser's Source 13সোর্স 13, and the script uses it to call Postman Echo.

const users = [
  { name: 'Asha', role: 'tester', active: true },
  { name: 'Rafi', role: 'developer', active: true },
  { name: 'Mina', role: 'tester', active: false },
];

const activeTesters = users
  .filter((user) => user.active && user.role === 'tester')
  .map((user) => user.name);
console.log(activeTesters); // [ 'Asha' ]

const firstDeveloper = users.find((user) => user.role === 'developer');
console.log(firstDeveloper.name); // Rafi

const text = JSON.stringify({ course: 'sdet', step: 3 });
console.log(JSON.parse(text).step === 3); // true

async function getEcho(course) {
  try {
    const response = await fetch(`https://postman-echo.com/get?course=${course}`);
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    const body = await response.json();
    return body.args.course;
  } catch (error) {
    console.error('Request failed:', error.message);
    throw error;
  }
}

console.log(await getEcho('sdet')); // sdet

It prints [ 'Asha' ], Rafi, true, and sdet. Now set Mina to active: true and run it again. The first line becomes [ 'Asha', 'Mina' ]. Guess the output before each run: it is a quick way to learn the array methods.

বাংলা ব্যাখ্যা

আপনার Node.js লাগবে। এটা users.mjs নামে সেভ করে node users.mjs চালান। .mjs extension file-টাকে ES module বানায় Source 12সোর্স 12, তাই এর top level-এ await কাজ করে Source 9সোর্স 9। Node.js-এ browser-এর মতো একটা fetch() আছে Source 13সোর্স 13, script-টা সেটা দিয়ে Postman Echo service-কে call করে।

const users = [
  { name: 'Asha', role: 'tester', active: true },
  { name: 'Rafi', role: 'developer', active: true },
  { name: 'Mina', role: 'tester', active: false },
];

const activeTesters = users
  .filter((user) => user.active && user.role === 'tester')
  .map((user) => user.name);
console.log(activeTesters); // [ 'Asha' ]

const firstDeveloper = users.find((user) => user.role === 'developer');
console.log(firstDeveloper.name); // Rafi

const text = JSON.stringify({ course: 'sdet', step: 3 });
console.log(JSON.parse(text).step === 3); // true

async function getEcho(course) {
  try {
    const response = await fetch(`https://postman-echo.com/get?course=${course}`);
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    const body = await response.json();
    return body.args.course;
  } catch (error) {
    console.error('Request failed:', error.message);
    throw error;
  }
}

console.log(await getEcho('sdet')); // sdet

Output হবে [ 'Asha' ], Rafi, true আর sdet। এবার Mina-কে active: true করে আবার চালান। প্রথম লাইন হবে [ 'Asha', 'Mina' ]। প্রতিবার চালানোর আগে output কী হবে আন্দাজ করুন: array method শেখার এটা একটা দ্রুত উপায়।

How a tester uses it

  • Test data. filter() keeps the items that pass a check, map() turns each item into a new value, and find() returns the first item that passes Source 6সোর্স 6. Use them to pick the records that a test needs from a larger list.
  • API responses. JSON.parse() turns a JSON string into a value Source 7সোর্স 7. Parse the body of a response, then check its fields. JSON.stringify() turns a value into a JSON string Source 14সোর্স 14: use it to build a JSON request body.
  • Waiting for results. await waits for a promise and returns its fulfilled value Source 9সোর্স 9. Use it before a call that returns a promise when the test needs that value.
  • Failures with context. Catch an error to log what the test was doing, then throw it again. The catch block runs only when the try block throws Source 10সোর্স 10.
  • Shared helpers. Put a helper, such as a login or a data builder, in a module, and import it in each test Source 12সোর্স 12.
  • Exact checks. Compare with ===, which treats values of different types as different Source 11সোর্স 11.

সহজ English

বাংলা ব্যাখ্যা

  • টেস্ট ডেটা। filter() চেকে পাস করা item রাখে, map() প্রতিটা item-কে নতুন value বানায়, আর find() প্রথম পাস করা item ফেরত দেয় Source 6সোর্স 6। বড় একটা list থেকে টেস্টের দরকারি record বেছে নিতে এগুলো ব্যবহার করুন।
  • API response। JSON.parse() একটা JSON string-কে value বানায় Source 7সোর্স 7। Response-এর body parse করে তারপর তার field চেক করুন। JSON.stringify() একটা value-কে JSON string বানায় Source 14সোর্স 14: JSON request body বানাতে এটা ব্যবহার করুন।
  • ফলাফলের জন্য অপেক্ষা। await একটা promise-এর জন্য অপেক্ষা করে আর তার fulfilled value দেয় Source 9সোর্স 9। Promise ফেরত দেয় এমন call-এর value টেস্টের দরকার হলে তার আগে এটা দিন।
  • কারণসহ failure। Error catch করে টেস্ট তখন কী করছিল তা লিখে রাখুন, তারপর error-টা আবার throw করুন। try block throw করলে তবেই catch block চলে Source 10সোর্স 10।
  • ভাগ করা helper। Login বা data builder-এর মতো helper একটা module-এ রাখুন, আর প্রতিটা টেস্টে import করুন Source 12সোর্স 12।
  • নির্ভুল চেক। === দিয়ে তুলনা করুন, এটা আলাদা type-এর value-কে আলাদা ধরে Source 11সোর্স 11।

Common mistakes

সহজ English

বাংলা ব্যাখ্যা

  • চেকে == ব্যবহার করা। Strict equality আলাদা type-এর value-কে আলাদা ধরে, তাই "1" === 1 হলো false Source 11সোর্স 11। === ব্যবহার করুন।
  • await বাদ পড়া। async function সবসময় একটা promise ফেরত দেয় Source 8সোর্স 8। এর fulfilled value পেতে promise-টা await করুন Source 9সোর্স 9।
  • const-এর ওপর বেশি ভরসা। const reference-টা স্থির করে, value-টা নয়, তাই const-এ রাখা object-এর property তবুও যোগ, বদল বা মুছে ফেলা যায় Source 4সোর্স 4।
  • JSON নয় এমন text parse করা। Text ঠিক JSON না হলে JSON.parse() একটা SyntaxError throw করে Source 7সোর্স 7। Body parse করার আগে response-এর status দেখুন।
  • খালি catch। try block throw করলে তার বদলে catch block চলে Source 10সোর্স 10। সেখানে error-এর খবর দেওয়ার কোড রাখুন, বা error-টা আবার throw করুন।

What a tester can check

Tutorial advice

This list is the tutorial's own advice, not a fact from a source.

  • Comparisons. Do the checks use === or the assertions of the test tool, never ==?
  • Awaits. Is every async call awaited? Look for a call to an async helper with no await in front.
  • Catch blocks. Does every catch log the context and throw again, or fail the test?
  • Test data. Is the data built from one source with filter() and map(), or copied by hand into many tests?
  • Helpers. Do the tests import shared helpers, or does each test paste its own copy?
  • Secrets. Do the scripts read tokens and passwords from the environment, not from the code?

সহজ English

Tutorial advice

This list is the tutorial's own advice, not a fact from a source.

  • Comparisons. Do the checks use === or the tool's own assertions, never ==?
  • Awaits. Is every async call awaited?
  • Catch blocks. Does every catch say what happened and throw again, or fail the test?
  • Test data. Is the data built from one place, or copied by hand into many tests?
  • Helpers. Do the tests share helpers with import, or paste copies?
  • Secrets. Are tokens and passwords kept out of the code?

বাংলা ব্যাখ্যা

Tutorial advice

এই তালিকা টিউটোরিয়ালের নিজের পরামর্শ, কোনো source থেকে নেওয়া তথ্য নয়।

  • তুলনা। চেকগুলো কি === বা টেস্ট টুলের নিজের assertion ব্যবহার করে, কখনো == নয়?
  • Await। প্রতিটা async call কি await করা? সামনে await ছাড়া কোনো async helper-এর call খুঁজুন।
  • Catch block। প্রতিটা catch কি কী হচ্ছিল তা লিখে error আবার throw করে, বা টেস্টকে fail করায়?
  • টেস্ট ডেটা। ডেটা কি এক জায়গা থেকে filter() আর map() দিয়ে তৈরি, নাকি অনেক টেস্টে হাতে কপি করা?
  • Helper। টেস্টগুলো কি shared helper import করে, নাকি প্রতিটা টেস্ট নিজের কপি বসায়?
  • Secret। Script কি token আর password environment থেকে পড়ে, কোড থেকে নয়?

Key words

TermMeaning
let / constBlock-scoped variables; a const cannot be re-assigned, but its object can still change.
PrimitiveOne of the seven simple data types, such as a string, a number, or a boolean.
Arrow functionA short way to write a function: (user) => user.name.
filter() / map() / find()Array methods: keep the items that pass, transform each item, return the first item that passes.
JSONText for data. JSON.stringify() writes it and JSON.parse() reads it.
PromiseThe value that an async function returns.
awaitWaits for a promise and returns its fulfilled value.
try...catchRuns the catch block when the try block throws.
Strict equality (===)A comparison that treats values of different types as different.
ES moduleA file that shares code with import and export, such as a .mjs file in Node.js.
Node.jsThe runtime that runs JavaScript outside the browser.
  1. [1]
    JavaScript

    MDN Web Docs (Mozilla) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  2. [2]
    Introduction to Node.js

    Node.js (OpenJS Foundation) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  3. [3]
    Grammar and types

    MDN Web Docs (Mozilla) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  4. [4]
    const

    MDN Web Docs (Mozilla) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  5. [5]
    Functions

    MDN Web Docs (Mozilla) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  6. [6]
    Indexed collections

    MDN Web Docs (Mozilla) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  7. [7]
    JSON.parse()

    MDN Web Docs (Mozilla) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  8. [8]
    async function

    MDN Web Docs (Mozilla) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  9. [9]
    await

    MDN Web Docs (Mozilla) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  10. [10]
    try...catch

    MDN Web Docs (Mozilla) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  11. [11]
    Strict equality (===)

    MDN Web Docs (Mozilla) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  12. [12]
    Modules: ECMAScript modules

    Node.js (OpenJS Foundation) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  13. [13]
    Global objects

    Node.js (OpenJS Foundation) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  14. [14]
    JSON.stringify()

    MDN Web Docs (Mozilla) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  15. [15]
    Write scripts to test API response data in Postman

    Postman · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  16. [16]
    Installation

    Playwright (Microsoft) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15