{"id":13651410,"url":"https://github.com/grafana/k6-template-typescript","last_synced_at":"2025-04-05T14:10:00.567Z","repository":{"id":41171308,"uuid":"270954907","full_name":"grafana/k6-template-typescript","owner":"grafana","description":"Template to use TypeScript with k6","archived":false,"fork":false,"pushed_at":"2024-08-30T22:40:13.000Z","size":704,"stargazers_count":279,"open_issues_count":15,"forks_count":66,"subscribers_count":146,"default_branch":"main","last_synced_at":"2024-10-29T16:45:30.185Z","etag":null,"topics":["javascript","k6","load-testing","performance-testing","templates","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grafana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-09T09:09:44.000Z","updated_at":"2024-10-29T12:02:58.000Z","dependencies_parsed_at":"2024-01-26T18:25:18.001Z","dependency_job_id":"a6ab4196-5bb1-47f5-b2f0-6c66aabc92a7","html_url":"https://github.com/grafana/k6-template-typescript","commit_stats":{"total_commits":57,"total_committers":11,"mean_commits":5.181818181818182,"dds":0.5087719298245614,"last_synced_commit":"7e83b52466a494ef19e3100484ffcc38d854fc8d"},"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-template-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-template-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-template-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-template-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grafana","download_url":"https://codeload.github.com/grafana/k6-template-typescript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345856,"owners_count":20924102,"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":["javascript","k6","load-testing","performance-testing","templates","typescript"],"created_at":"2024-08-02T02:00:49.166Z","updated_at":"2025-04-05T14:10:00.543Z","avatar_url":"https://github.com/grafana.png","language":"TypeScript","funding_links":[],"categories":["typescript","Examples/Templates"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \n  ![banner](docs/ts-js-k6.png)\n\n# Template to use TypeScript with k6\n\n![.github/workflows/push.yml](https://github.com/grafana/k6-template-typescript/workflows/.github/workflows/push.yml/badge.svg?branch=main)\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 maintainability.\n- Allow you to drop a lot of the defensive code previously needed to make sure consumers are calling functions properly.\n\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/grafana/k6-template-typescript) page and click **Use this template**.\n\n  ![](docs/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\nnpm 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 running a bundler. This project uses `Babel` and `Webpack` to bundle the different files into ES modules (ESM), using its [`webpack.config.js`](./webpack.config.js) configuration.\n\nThe next command transforms each TypeScript test in `./src` to the `./dist` folder as ES modules.\n\n```bash\nnpm run bundle\n```\n\nOnce that is done, we can run our script the same way we usually do, for instance:\n\n```bash\nk6 run dist/get-200-status-test.js\n```\n\n**See also**\n\n- [Using k6 / Modules](https://grafana.com/docs/k6/latest/using-k6/modules/)\n- [Using k6 / JavaScript compatibility mode](https://grafana.com/docs/k6/latest/using-k6/javascript-compatibility-mode/)\n- [grafana/k6-rollup-example](https://github.com/grafana/k6-rollup-example)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fk6-template-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrafana%2Fk6-template-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fk6-template-typescript/lists"}