{"id":13342892,"url":"https://github.com/grafana/xk6-ts","last_synced_at":"2025-10-19T10:31:25.628Z","repository":{"id":153532988,"uuid":"625197000","full_name":"grafana/xk6-ts","owner":"grafana","description":"TypeScript support for k6","archived":false,"fork":false,"pushed_at":"2025-01-06T09:37:22.000Z","size":90,"stargazers_count":18,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T08:04:02.419Z","etag":null,"topics":["typescript","xk6","xk6-other"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.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":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-08T11:10:00.000Z","updated_at":"2025-01-06T09:37:27.000Z","dependencies_parsed_at":"2024-04-23T09:01:14.143Z","dependency_job_id":"2a1fa791-6fd6-4b77-aad6-2c47b1cc0527","html_url":"https://github.com/grafana/xk6-ts","commit_stats":null,"previous_names":["szkiba/xk6-ts","grafana/xk6-ts"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grafana","download_url":"https://codeload.github.com/grafana/xk6-ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237110169,"owners_count":19257279,"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":["typescript","xk6","xk6-other"],"created_at":"2024-07-29T19:30:06.672Z","updated_at":"2025-10-19T10:31:25.623Z","avatar_url":"https://github.com/grafana.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xk6-ts\n\n\u003e[!WARNING]\n\u003eThis extension is deprecated because its functionality [has been included in k6](https://grafana.com/docs/k6/latest/using-k6/javascript-typescript-compatibility-mode/).\n\n**TypeScript support for k6**\n\nxk6-ts makes TypeScript a first-class citizen in k6.\n\n```sh\nk6 run script.ts\n```\n\n\u003cdetails\u003e\n\u003csummary\u003escript.ts\u003c/summary\u003e\n\n```ts file=examples/script.ts\nimport { User, newUser } from \"./user\";\n\nexport default () =\u003e {\n  const user: User = newUser(\"John\");\n  console.log(user);\n};\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003euser.ts\u003c/summary\u003e\n\n```ts file=examples/user.ts\ninterface User {\n  name: string;\n  id: number;\n}\n\nclass UserAccount implements User {\n  name: string;\n  id: number;\n\n  constructor(name: string) {\n    this.name = name;\n    this.id = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);\n  }\n}\n\nfunction newUser(name: string): User {\n  return new UserAccount(name);\n}\n\nexport { User, newUser };\n```\n\n\u003c/details\u003e\n\nThat's it. A test written in TypeScript can be run directly with k6. No need for Node.js, babel, webpack, bundler, build step, etc.\n\nDo you think modern JavaScript features make TypeScript pointless? xk6-ts can also be used to support modern JavaScript features in k6. \n\n```sh\nk6 run script.js\n```\n\n\u003cdetails\u003e\n\u003csummary\u003escript.js\u003c/summary\u003e\n\n```ts file=examples/script.js\nimport { newUser } from \"./user\";\n\nexport default () =\u003e {\n  const user = newUser(\"John\");\n  console.log(user);\n};\n```\n\n\u003c/details\u003e\n\n\nxk6-ts can be disabled by setting the `XK6_TS` environment variable to `false`.\n\nTo ensure that runtime error messages report the correct source code position, sourcemap generation is enabled by default. Otherwise, due to transpilation and bundling, the source code position is meaningless.\nSourcemap generation can be disabled by setting the value of the `XK6_TS_SOURCEMAP` environment variable to `false`.\n\n## Features\n\n - TypeScript language support\n    ```bash\n    k6 run script.ts\n    ```\n - remote (https) TypeScript/JavaScript module support\n    ```js\n    import { User } from 'https://example.com/user.ts'\n    console.log(new User())\n    ```\n\n - importing JSON files as JavaScript object\n    ```js\n    import object from './example.json'\n    console.log(object)\n    ```\n - importing text files as JavaScript string\n    ```js\n    import string from './example.txt'\n    console.log(string)\n    ```\n - mix and match JavaScript and TypeScript\n   - import TypeScript module from JavaScript module\n   - import JavaScript module from TypeScript module\n\n## Download\n\nYou can download pre-built k6 binaries from [Releases](https://github.com/szkiba/xk6-ts/releases/) page. Check [Packages](https://github.com/szkiba/xk6-ts/pkgs/container/xk6-ts) page for pre-built k6 Docker images.\n\n## Build\n\nThe [xk6](https://github.com/grafana/xk6) build tool can be used to build a k6 that will include xk6-faker extension:\n\n```bash\n$ xk6 build --with github.com/szkiba/xk6-ts@latest\n```\n\nFor more build options and how to use xk6, check out the [xk6 documentation](https://github.com/grafana/xk6).\n\n## How It Works\n\nUnder the hood, xk6-ts uses the [esbuild](https://github.com/evanw/esbuild) library for transpiling and bundling. To be precise, xk6-ts uses the [k6pack](https://github.com/grafana/k6pack) library, which is based on esbuild.\n\nBefore the test run, transpilation and bundling are done on the fly.\n\n## Compatibility warning\n\nxk6-ts is currently integrated into k6 by modifying the execution of the `k6 run` command. This is a temporary solution, the final integration will be done in a different way. This temporary integration assumes that the last argument of the `k6 run` command line is the name of the script file. That is, contrary to the way the original `k6 run` command line works, xk6-ts does not accept flags after the script file name. By the way, this assumption is not uncommon, many other commands only accept flags before positional arguments. (the original `k6 run` command also accepts flags after the positional argument).\n\n## Benchmarking\n\nSetting the `XK6_TS_BENCHMARK` environment variable to `true` will log the time spent on TypeScript/JavaScript bundling. This time also includes downloading any remote modules.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fxk6-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrafana%2Fxk6-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fxk6-ts/lists"}