{"id":17780696,"url":"https://github.com/oleiade/k6-testing","last_synced_at":"2026-02-04T09:35:35.994Z","repository":{"id":258109467,"uuid":"870543274","full_name":"oleiade/k6-testing","owner":"oleiade","description":"[prototype] Functional testing primitives for k6","archived":false,"fork":false,"pushed_at":"2024-10-28T09:52:23.000Z","size":48,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T18:46:00.445Z","etag":null,"topics":["functional-testing","grafana","javascript","jslib","k6","testing","typescript"],"latest_commit_sha":null,"homepage":"https://grafana.com/docs/k6/latest/","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/oleiade.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":"2024-10-10T08:28:00.000Z","updated_at":"2024-10-28T09:52:27.000Z","dependencies_parsed_at":"2025-04-09T19:04:46.302Z","dependency_job_id":"c37605de-03f6-4108-a830-330d00e31fc8","html_url":"https://github.com/oleiade/k6-testing","commit_stats":null,"previous_names":["oleiade/k6-testing"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/oleiade/k6-testing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleiade%2Fk6-testing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleiade%2Fk6-testing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleiade%2Fk6-testing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleiade%2Fk6-testing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oleiade","download_url":"https://codeload.github.com/oleiade/k6-testing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleiade%2Fk6-testing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266393621,"owners_count":23922425,"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","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["functional-testing","grafana","javascript","jslib","k6","testing","typescript"],"created_at":"2024-10-27T03:03:34.371Z","updated_at":"2026-02-04T09:35:35.963Z","avatar_url":"https://github.com/oleiade.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# k6-testing\n\nA seamless way to write functional tests in k6 with Playwright-compatible assertions.\n\n\u003e ⚠️ **Note**: This is a prototype project demonstrating the concept. Not yet ready for production use.\n\n## Why k6-testing?\n\n- **✨ Write once, run anywhere**: Copy-paste your Playwright test assertions directly into k6 - they'll work out of the box\n- **🎯 Fail fast**: Tests interrupt immediately when assertions fail, giving you quick, clear feedback\n- **🔄 Progressive API**: Start simple with `assert`, scale up to expressive `expect` assertions as your needs grow\n- **🎭 Familiar API**: Familiar API for anyone coming from Playwright, Deno, or Vite ecosystem\n- **🔍 Clear error messages**: Get detailed, actionable feedback when tests fail\n\n## Installation\n\n```sh\ndeno task build\n```\n\n## Quick Start\n\n```javascript\nimport { expect } from \"https://github.com/oleiade/k6-testing/releases/download/v0.2.0/index.js\";\n\nexport default function () {\n  // Simple assertions\n  expect(response.status).toBe(200);\n  \n  // Async assertions with retry (perfect for UI testing)\n  await expect(page.locator('.submit-button')).toBeEnabled();\n  \n  // Soft assertions - continue testing even after failures\n  expect.soft(data.userId).toBeDefined();\n}\n```\n\nFor functional testing, metrics and performance are most likely irrelevant, and we recommend executing k6 functional tests in headless mode:\n\n```sh\n# Run k6 in headless mode\nk6 run --no-summary --quiet examples/browser.js\n\n# If any assertion/expectation fail, a non-zero exit code will be returned\necho $status\n```\n\n## Features\n\n### 1. Playwright-Compatible Expectations\n\nUse the same assertions you know from Playwright:\n\n```javascript\n// These Playwright assertions work exactly the same in k6\nawait expect(page.locator('.button')).toBeVisible();\nawait expect(page.locator('input')).toHaveValue('test');\n```\n\n### 2. Auto-Retrying Assertions\n\n\nPerfect for UI testing, these assertions will retry until the assertion passes, or the assertion timeout is reached. Note that retrying assertions are async, so you must await them.\nBy default, the timeout for assertions is set to 5 seconds, and the polling interval is set to 100 milliseconds. \n\n| Assertion            | Description                |\n|----------------------|----------------------------|\n| `toBeChecked()`      | Element is checked         |\n| `toBeDisabled()`     | Element is disabled        |\n| `toBeEditable()`     | Element is editable        |\n| `toBeEnabled()`      | Element is enabled         |\n| `toBeHidden()`       | Element is hidden          |\n| `toBeVisible()`      | Element is visible         |\n| `toHaveValue(value)` | Element has specific value |\n\nYou can customize these values by passing an options object as the second argument to the assertion function:\n  \n  ```javascript\n  await expect(page.locator('.button')).toBeVisible({ timeout: 10000, interval: 500 });\n  ```\n\n### 3. Standard Assertions\n\nThese assertions allow to test any conditions, but do not auto-retry.\n\n| Assertion                         | Description                      |\n|-----------------------------------|----------------------------------|\n| `toBe(expected)`                  | Strict equality comparison       |\n| `toEqual(expected)`               | Deep equality comparison         |\n| `toBeCloseTo(number, precision?)` | Number comparison with precision |\n| `toBeTruthy()`                    | Truthy value check               |\n| `toBeFalsy()`                     | Falsy value check                |\n| `toBeGreaterThan(number)`         | Greater than comparison          |\n| `toBeLessThan(number)`            | Less than comparison             |\n\n### 4. Soft Assertions\n\nKeep tests running even after failures - perfect for collecting multiple failures in one run:\n\n```javascript\n// Test continues even if assertions fail\nexpect.soft(response.status).toBe(200);\nexpect.soft(data.items).toHaveLength(5);\n```\n\n### 5. Basic Assertions\n\nLow-level assertions for simple cases:\n\n```javascript\nimport { assert, assertEquals } from \"k6-testing\";\n\nassert(condition, \"error message\");\nassertEquals(actual, expected, \"error message\");\n```\n\n## Progressive Testing Approach\n\nk6-testing offers multiple layers of assertion capabilities:\n\n1. **Basic**: Start with simple `assert()` for straightforward checks\n2. **Standard**: Use `expect()` for more expressive assertions\n3. **Advanced**: Leverage retrying assertions for robust UI testing\n4. **Comprehensive**: Combine with soft assertions for thorough test coverage\n\n## Error Handling\n\nGet clear, actionable error messages:\n\n```javascript\nexpect(value).toBe(expected);\n// Error: Expected value to be undefined\n//   Expected: undefined\n//   Received: \"actual value\"\n```\n\n## Contributing\n\nContributions are welcome! Check out our [Contributing Guide](CONTRIBUTING.md) for details.\n\n## License\n\n[MIT License](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleiade%2Fk6-testing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foleiade%2Fk6-testing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleiade%2Fk6-testing/lists"}