{"id":13817055,"url":"https://github.com/JairusSW/as-test","last_synced_at":"2025-05-15T18:32:46.982Z","repository":{"id":240856853,"uuid":"803598135","full_name":"JairusSW/as-test","owner":"JairusSW","description":"Testing framework for AssemblyScript. Compatible with WASI or Bindings","archived":false,"fork":false,"pushed_at":"2025-03-12T21:26:23.000Z","size":496,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-08T20:47:54.876Z","etag":null,"topics":["as-pect","aspect","assemblyscript","test","testing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JairusSW.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2024-05-21T03:13:18.000Z","updated_at":"2025-03-12T21:26:27.000Z","dependencies_parsed_at":"2024-06-03T21:31:47.740Z","dependency_job_id":"b4ad5e3e-3d53-4991-a1c2-f39a06d66e23","html_url":"https://github.com/JairusSW/as-test","commit_stats":null,"previous_names":["jairussw/as-test"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JairusSW%2Fas-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JairusSW%2Fas-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JairusSW%2Fas-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JairusSW%2Fas-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JairusSW","download_url":"https://codeload.github.com/JairusSW/as-test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254397972,"owners_count":22064591,"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":["as-pect","aspect","assemblyscript","test","testing"],"created_at":"2024-08-04T06:00:32.620Z","updated_at":"2025-05-15T18:32:46.976Z","avatar_url":"https://github.com/JairusSW.png","language":"TypeScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"\u003ch5 align=\"center\"\u003e\n  \u003cpre\u003e\n\u003cspan style=\"font-size: 0.8em;\"\u003e █████  ███████       ████████ ███████ ███████ ████████ \n██   ██ ██               ██    ██      ██         ██    \n███████ ███████ █████    ██    █████   ███████    ██    \n██   ██      ██          ██    ██           ██    ██    \n██   ██ ███████          ██    ███████ ███████    ██    \n                                                        \u003c/span\u003e\n    AssemblyScript - v0.4.1\n\u003c/pre\u003e\n\u003c/h5\u003e\n\nA lightweight testing framework for AssemblyScript.\n\n🔹 Minimal and fast – Run your tests without unnecessary overhead.\n\n🔹 Familiar API – Inspired by modern JavaScript testing frameworks.\n\n🔹 Powerful mocking – Easily override functions and track calls.\n\n🔹 Seamless CI/CD integration – Works effortlessly in automation pipelines.\n\n🔹 Universal environment – Run your tests on any platform, runtime, or bindings.\n\n## 💾 Installation\n\n```bash\nnpm install as-test\n```\n\nInitialize your test setup with:\n\n```bash\nas-test init\n```\n\nThis creates a test directory at `assembly/__tests__/` with a sample test file.\n\n## 📝 Writing Tests\n\nCreate a new test file in `assembly/__tests__/`, for example, `math.spec.ts`:\n\n```js\nimport { describe, test, expect, run } from \"as-test\";\n\ndescribe(\"Math operations\", () =\u003e {\n  test(\"Addition\", () =\u003e {\n    expect(1 + 2).toBe(3);\n  });\n\n  test(\"Subtraction\", () =\u003e {\n    expect(5 - 2).toBe(3);\n  });\n\n  test(\"Multiplication\", () =\u003e {\n    expect(3 * 3).toBe(9);\n  });\n});\n\nrun();\n```\n\n## 🔍 Examples\n\n### 🏗️ Mocking Functions\n\nUse `mockFn` to override functions during testing:\n\n```js\nimport { mockFn } from \"as-test\";\n\n// Mock console.log\nmockFn\u003cvoid\u003e(\"console.log\", (data: string): void =\u003e {\n    console.log(\"[MOCKED]: \" + data);\n});\n\nrun();\n```\n\nOr override imported functions with `mockImport`.\n\n### ⚒️ Setup and Teardown\n\nUse `beforeAll` and `afterAll` to run code before and after a test is run.\n\n```js\nimport { beforeAll, afterAll } from \"as-test\";\n\nbeforeAll(() =\u003e {\n  log(\"Setting up test environment...\");\n});\n\nafterAll(() =\u003e {\n  log(\"Tearing down test environment...\");\n});\n\nrun();\n```\n\n### 📃 Pretty Logging\n\nUsing `console.log` will mess up the terminal output. Instead, use the inbuilt `log` function:\n\n```js\nimport { log } from \"as-test\";\n\nlog(\"This is a pretty log function\");\n\nrun();\n```\n\nOr override all existing `console.log` calls with `log`:\n\n```js\nimport { mockFn, log } from \"as-test\";\n\nmockFn\u003cvoid\u003e(\"console.log\", (data: string): void =\u003e {\n    log(data);\n});\n\nrun();\n```\n\n### 🔄 Running Tests in CI\n\nTo integrate `as-test` into your CI/CD workflow, see the [example configuration](https://github.com/JairusSW/as-test/blob/main/.github/workflows/as-test.yml).\n\n`assembly/__tests__/example.spec.ts`\n\n## 📃 License\n\nThis project is distributed under an open source license. You can view the full license using the following link: [License](./LICENSE)\n\n## 📫 Contact\n\nPlease send all issues to [GitHub Issues](https://github.com/JairusSW/as-test/issues) and to converse, please send me an email at [me@jairus.dev](mailto:me@jairus.dev)\n\n- **Email:** Send me inquiries, questions, or requests at [me@jairus.dev](mailto:me@jairus.dev)\n- **GitHub:** Visit the official GitHub repository [Here](https://github.com/JairusSW/as-test)\n- **Website:** Visit my official website at [jairus.dev](https://jairus.dev/)\n- **Discord:** Contact me at [My Discord](https://discord.com/users/600700584038760448) or on the [AssemblyScript Discord Server](https://discord.gg/assemblyscript/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJairusSW%2Fas-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJairusSW%2Fas-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJairusSW%2Fas-test/lists"}