{"id":25109890,"url":"https://github.com/glific/k6io","last_synced_at":"2025-04-02T09:25:31.145Z","repository":{"id":42707431,"uuid":"295876423","full_name":"glific/k6io","owner":"glific","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-06T14:32:32.000Z","size":2010,"stargazers_count":0,"open_issues_count":13,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-08T00:32:33.379Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/glific.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-15T23:55:35.000Z","updated_at":"2020-09-23T13:23:20.000Z","dependencies_parsed_at":"2023-02-06T05:16:08.206Z","dependency_job_id":null,"html_url":"https://github.com/glific/k6io","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"grafana/k6-template-typescript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glific%2Fk6io","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glific%2Fk6io/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glific%2Fk6io/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glific%2Fk6io/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glific","download_url":"https://codeload.github.com/glific/k6io/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246786612,"owners_count":20833721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-08T00:32:39.060Z","updated_at":"2025-04-02T09:25:31.118Z","avatar_url":"https://github.com/glific.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \n  ![banner](assets/ts-js-k6.png)\n\n# Template to use TypeScript with k6\n\n![.github/workflows/push.yml](https://github.com/k6io/template-typescript/workflows/.github/workflows/push.yml/badge.svg?branch=master)\n\n\u003c/div\u003e\n\nThis repository provides a scaffolding project to start using TypeScript in your k6 scripts.\n\n## Rationale\n\nWhile 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.\n\nWhile 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:\n\n- Improve the ability to safely refactor your code.\n- Improve readability and maintainablity.\n- Allow you to drop a lot of the defensive code previously needed to make sure consumers are calling functions properly.\n\n\n## Prerequisites\n\n- [k6](https://k6.io/docs/getting-started/installation)\n- [NodeJS](https://nodejs.org/en/download/)\n- [Yarn](https://yarnpkg.com/getting-started/install) (optional)\n\n## Installation\n\n**Creating a project from the `template-typescript` template**\n\nTo generate a TypeScript project that includes the dependencies and initial configuration, navigate to the [template-typescript](https://github.com/k6io/template-typescript) page and click **Use this template**.\n\n  ![](assets/use-this-template-button.png)\n\n\n**Install dependencies**\n\nClone the generated repository on your local machine, move to the project root folder and install the dependencies defined in [`package.json`](./package.json)\n\n```bash\n$ yarn install\n```\n\n## Running the test\n\nTo run a test written in TypeScript, we first have to transpile the TypeScript code into JavaScript and bundle the project\n\n```bash\n$ yarn webpack\n```\n\nThis command creates the final test files to the `./dist` folder.\n\nOnce that is done, we can run our script the same way we usually do, for instance:\n\n```bash\n$ k6 run dist/test1.js\n```\n\n### Transpiling and Bundling\n\nBy default, k6 can only run ES5.1 JavaScript code. To use TypeScript, we have to set up a bundler that converts TypeScript to JavaScript code. \n\nThis project uses `Babel` and `Webpack` to bundle the different files - using the configuration of the [`webpack.config.js`](./webpack.config.js) file.\n\nIf you want to learn more, check out [Bundling node modules in k6](https://k6.io/docs/using-k6/modules#bundling-node-modules).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglific%2Fk6io","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglific%2Fk6io","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglific%2Fk6io/lists"}