JavaScript ES6 Modules: Export, Import, Named vs Default (JS for QA)

Опубликовано: 22 Июль 2026
на канале: QA Thoughts
166
9

‪@QAThoughts‬ This video explains about Modules in Javascript & how to use export, import keywords in JS. If you are trying to build a scalable Test Automation Framework? You cannot do it without mastering JavaScript Modules.

In this video, we move away from writing all our code in a single file. I explain how to split your code into reusable files using ES6 Modules (import and export). This is the foundation for the Page Object Model (POM) design pattern used in Playwright, Cypress, and WebdriverIO.

We also cover the critical setup step in package.json that most beginners miss, which causes the infamous "Cannot use import statement outside a module" error.

Topics Covered in this Video:
00:00 - Introduction: Why use Modules?
00:45 - What is the Export Keyword?
00:58 - Named Export vs. Default Export explained
01:09 - Important Setup: Setting "type": "module" in package.json
03:45 - Demo: Exporting Variables, Functions, and Classes
04:55 - Importing Named Exports (Using curly braces {})
05:14 - Importing Default Exports (Custom naming)
06:47 - Running the code with Node.js
08:40 - Summary

Must know JS topics:

Async-await in JS:
   • JavaScript Async Await Explained: Stop Usi...  

Promise in JS:
   • JavaScript Promises Explained: .then(), .c...  

Callback Hell in JS:
   • What is Callback Hell in JavaScript? The "...  

Callback function in JS:
   • Callback Function In JavaScript | To handl...  

#javascript #testing