Gatling doubles its availability with a new JavaScript SDK

4 min read
May 23, 2024 2:56:30 PM

Today, we are thrilled to announce that we have added a JavaScript and TypeScript SDK for Gatling load tests. The new JavaScript SDK is the first enterprise-grade load-testing tool on the npm registry, doubling the number of developers who can use Gatling in their own programming language.  

SDKs Javascript and Typescript HD

Join us, and deliver the most performant applications, APIs, and websites to your users!  

Since its introduction, Gatling has been a Java Virtual Machine (JVM)- based developer tool focused on load testing. Now, developers can write load tests with the Gatling JavaScript SDK and compile the tests to run on a JVM. This combines the power of a scripting language with necessary performance features like multithreading. 

The great thing, is you no longer have to be a Java developer to use Gatling. From setting up your project with an npm install command to familiar syntax, JavaScript developers will feel at home working with the SDK but know they have the power of the Gatling Engine to run their load tests. 

Read on to learn more about how and why we developed a JavaScript SDK, but more importantly, how to try it out.  

 

Why did we develop the JavaScript and TypeScript SDK for Gatling?

There is no denying the amazing evolution of the JavaScript ecosystem. In the early days, it was a front-end scripting language. With the addition of NodeJS and TypeScript, it is now a full-stack, type-safe language for developers building modern web applications and APIs. By at least 1 estimate, JavaScript is part of the tech stack for 98% of Fortune 500 companies.  

 

The JavaScript and Java Story

The history of Java and JavaScript is linked from the very beginning. Both languages were developed in Silicon Valley and released in 1995. JavaScript was initially named Mocha, but Netscape renamed it as a marketing initiative to exploit Java’s growing popularity. 

Over the years, the two languages have been largely complementary, with Java as a server-side powerhouse and JavaScript powering browser-based websites and applications. From the beginning, developers at Netscape realized the potential of running JavaScript server-side. 

In 1997, Netscape began working on Rhino, a JavaScript engine capable of running on a JVM. Rhino had both a compiled and interpreted version but still suffered from performance issues. Oracle later developed Nashorn to replace Rhino. Oracle included  Nashorn in Java 8 but deprecated it with Java 11 because the JavaScript ecosystem was evolving too quickly to maintain support for the implementation. 

Shortly after deprecating Nashorn, Oracle released the first version of GraalVM. GraalVM is a Java Development Kit (JDK) that is available in both community and enterprise versions. GraalVM is an alternative to the popular OpenJDK and includes the following functionalities: 

  • Graal Compiler, a just-in-time (JIT) compiler.
  • GraalVM Native Image compiles Java applications in advance.
  • Truffle Language Implementation Framework and GraalVM SDK provide a Java-based framework for implementations with other programming languages, including APIs for developing high-performance language runtimes.
  • GraalVM Polyglot API embeds guest language code in a Java host application.
  • JavaScript Runtime, an ECMAScript 2023-compliant JavaScript runtime, and Node.js runtime.
  • LLVM Runtime executes languages that can be translated into LLVM bitcode.

GraalVM promises true interoperability between JavaScript and Java developers with its runtime for JavaScript and NodeJS. The release of GraalVM also motivated Gatling’s developers to start working on our own JavaScript SDK. 

 

Some of the technical details

The goal of the SDK is to allow Gatling users to write load-testing simulations entirely in JavaScript or TypeScript. Users can also include their favorite libraries from npm while leveraging Gatling’s robust and well-tested code base.

To achieve this, we run on GraalVM, a polyglot virtual machine (capable of running code written in several different programming languages inside the same environment). The JavaScript support comes from the GraalJS project.

When you script a simulation in JavaScript, all your calls to the SDK get translated into calls to the Gatling Java SDK. The simulation can then run on the same Gatling engine as simulations written in Java, Kotlin, or Scala.

The only prerequisite for using JavaScript or TypeScript is NodeJS (with npm installed). When you run your first load test, the Gatling-js CLI downloads GraalVM and some Java libraries to enable the Gatling engine. 

The JavaScript SDK also supports the Gatling Recorder, an application that lets you capture browser-based user actions and convert them into a load-testing script. If you are new to crafting load tests, the Recorder is another great tool for learning scripting for more complex scenarios. 

 

What is coming next? 

Our first release of the Gatling JavaScript SDK covers nearly all the HTTP protocol functionality that is available in the Java SDK. It is available to all Gatling users as part of our open-core commitment and Apache 2.0 license. The team is actively working on 3 projects to expand the developer experience for JavaScript developers: 

  • Support JavaScript and TypeScript on Gatling Enterprise.
  • Expand the SDK to cover additional protocols like WebSocket and gRPC.

Specifically, we know some of our existing customers are very excited to expand Gatling usage to their JavaScript and TypeScript developers, so adding support for Gatling Enterprise is underway. We will share more details in the coming weeks. 

 

How to get started

The following resources will help you get started with the Gatling JavaScript SDK: 

In addition to the preceding resources, JavaScript-specific code examples are provided throughout the Documentation. Alerts have also been added to specific features that are not yet available for JavaScript and TypeScript. 

 

Feedback is welcome!

This is an early release, so now is the best time to tell us what works well and what could be improved. Tell us what you think in the Gatling Community, and if you find a bug, open a GitHub Issue. You can view and comment on our public product roadmap if you want to help shape how we expand the Gatling JavaScript SDK.