A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/grafana/k6-template-typescript below:

grafana/k6-template-typescript: Template to use TypeScript with k6

Template to use TypeScript with k6

This repository provides a scaffolding project to start using TypeScript in your k6 scripts.

While JavaScript is great for a myriad of reasons, one area where it fall short is type safety and developer ergonomics. It's perfectly possible to write JavaScript code that will look OK and behave OK until a certain condition forces the executor into a faulty branch.

While it, of course, still is possible to shoot yourself in the foot with TypeScript as well, it's significantly harder. Without adding much overhead, TypeScript will:

Creating a project from the template-typescript template

To generate a TypeScript project that includes the dependencies and initial configuration, navigate to the template-typescript page and click Use this template.

Install dependencies

Clone the generated repository on your local machine, move to the project root folder and install the dependencies defined in package.json

To run a test written in TypeScript, we first have to transpile the TypeScript code into JavaScript running a bundler. This project uses Babel and Webpack to bundle the different files into ES modules (ESM), using its webpack.config.js configuration.

The next command transforms each TypeScript test in ./src to the ./dist folder as ES modules.

Once that is done, we can run our script the same way we usually do, for instance:

k6 run dist/get-200-status-test.js

See also


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4