New job? New toolset to explore! In this post I'll be investigating a new JavaScript package manager and runtime environment called
bun.sh.
You may have noticed on Playwright.Dev's
Getting Started / Installation section there are three different ways to install a ui or api test automation framework with the latest version of Playwright:
- npm init playwright@latest
- yarn create playwright
- pnpm create playwright
For this blog post I'll be investigating a fourth way, the new toolset they just started using at work,
bun.sh.
What is npm, yarn, pnpm, and bun? These are called package managers.
What is a package? Developing a project, you don't have to figure out how to code everything yourself. You can include in your projects outside libraries, or "packages" of code from from the public JavaScript registry
npmjs.com.
The problem is that these packages then need to be downloaded, installed, managed, and updated whenever they are updated. JavaScript projects can use a package manager, such as bun, to help this process.
When putting together a Playwright automation framework based around JavaScript and TypeScript, Playwright uses the Node.js JavaScript runtime environment, to run its test runner, execute automation scripts, and manage its browser instances.(See
Nodejs.org / About )
There is a division of labor: Node.js runs these internal functions like running tests. NPM, Yarn, PNPM, and now Bun handle the packages.
Why are there so many package managers? Each has its own specialization. The original NPM is bundled already with Node.js. Yarn is a Facebook toolset that was created when NPM was found to work too slow. PNPM was created to be smaller and therefore faster. And bun was built for quick startup and installation speed, good especially if you have a CI/ CD pipeline that has a LOT of packages to install each time the tests run.