{"id":25774437,"url":"https://github.com/markusand/testamenta","last_synced_at":"2026-05-26T16:35:27.763Z","repository":{"id":256481477,"uuid":"855436691","full_name":"markusand/testamenta","owner":"markusand","description":"Lightweight, dependency-free test framework to run in the browser","archived":false,"fork":false,"pushed_at":"2024-12-27T11:55:56.000Z","size":202,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-27T12:28:05.364Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markusand.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-09-10T21:35:07.000Z","updated_at":"2024-12-27T11:54:41.000Z","dependencies_parsed_at":"2024-09-11T02:14:53.453Z","dependency_job_id":"68b4fcb9-d6b9-4d2d-a9df-9b658ce6e489","html_url":"https://github.com/markusand/testamenta","commit_stats":null,"previous_names":["markusand/testamenta"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusand%2Ftestamenta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusand%2Ftestamenta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusand%2Ftestamenta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusand%2Ftestamenta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markusand","download_url":"https://codeload.github.com/markusand/testamenta/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240983671,"owners_count":19888738,"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-27T05:29:58.445Z","updated_at":"2026-05-26T16:35:27.735Z","avatar_url":"https://github.com/markusand.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Testamenta\n\nLightweight, dependency-free test framework with a **Jest-like public API**. Useful for environments where bundlers and Node.js are not required, it allows you to test JavaScript code directly in the browser via a simple `\u003cscript\u003e` import.\n\n## Key Features\n\n- **📖 Jest-like API**: Offers a public interface very similar to Jest (with its obvious limitations), making it intuitive for users already familiar with popular testing frameworks.\n\n- **📦 No Setup**: Requires no installation or package management—simply import the framework using a script tag.\n\n- **⏳ Async-Aware**: Supports asynchronous test execution via `async/await`.\n\n- **🔍 Mocking and Spying**: Built-in support for mock and spy functions and call tracking.\n\n- **📝 Flexible Logging**: Outputs results to the console and the DOM.\n\n## Getting Started\n\nCopy the `testamenta.js` file to your project or import it from a CDN [unpkg](http://unpkg.com/testamenta) | [jsdelivr](https://cdn.jsdelivr.net/npm/testamenta).\n\nIt can also be installed with [npm](https://www.npmjs.com/package/testamenta), but it doesn't make much sense having more complete and robust options like **Jest**.\n\n```html\n// test.html\n\n\u003cscript type=\"module\"\u003e\n  import { tests } from 'https://unpkg.com/testamenta';\n\n  tests(['utils', 'plugins'], {\n    path: new URL('.', import.meta.url).href, // path to test files\n  });\n\u003c/script\u003e\n```\n\nCreate test files named as `*.test.js` to be properly loaded. Test files use a syntax similar to [Jest](https://jestjs.io/docs/en/getting-started).\n\n\u003e [!WARNING]\n\u003e The call to `describe` must be awaited to properly run tests sequentially.\n\n```js\nimport { describe, it, expect } from 'https://unpkg.com/testamenta';\n\nawait describe('Math operations', () =\u003e {\n  it('should add two numbers', () =\u003e {\n    expect(1 + 2).toBe(3);\n  });\n});\n```\n\nBoth `describe` and `it` can be asynchronous and use **async/await**, and skipped by using  the `skip` modifier.\n\n```js\nimport { describe, it, expect } from 'https://unpkg.com/testamenta';\n\nawait describe('Promises', () =\u003e {\n  it('should await for a Promise', async () =\u003e {\n    const value = await new Promise(resolve =\u003e {\n      setTimeout(() =\u003e resolve(1), 1000);\n    });\n    expect(value).toBe(1);\n  });\n});\n```\n\n`beforeAll` and `afterAll` can be used to setup and clean resource for the hole test suite (tests inside `describe`).\n\n`beforeEach` and `afterEach` can be used to setup and clean up resources before and after each test in a suite. Returned value in beforeEach is passed as parameter to all it functions.\n\nMocking and spying functions is supported, allowing you to simulate and track function calls during test execution.\n\n```js\nimport { describe, it, expect, beforeEach, mockFn, spyOn } from 'https://unpkg.com/testamenta';\n\nconst openWindow = spyOn(window, 'open');\n\nawait describe('Mocking', () =\u003e {\n  const mock = mockFn();\n\n  beforeEach(() =\u003e mock.reset());\n\n  it('should mock a function', () =\u003e {\n    mock(1, 2);\n    mock(3, 4);\n\n    expect(mock)\n      .toHaveBeenCalledTimes(2);\n      .toHaveBeenCalledWith(1, 2);\n\n    expect(openWindow).toHaveBeenCalled();\n  });\n})\n```\n\n## Assertion\n\nThe `expect` function allows for assertions within test cases. It provides a wide range of built-in matchers for testing various conditions:\n\n- `toBe` Asserts strict equality.\n- `toBeTruthy` Asserts that a value is truthy.\n- `toBeBoolean`, `toBeNumber`, `toBeString`, `toBeArray`, `toBeDate`, `toBeObject`, `toBeFunction`: Type checks for primitives, objects and functions.\n- `toHaveLength`: Asserts the length of an array or string.\n- `toContain`: Verifies that an array, object or string contains a specific value.\n- `toHaveBeenCalled`, `toHaveBeenCalledTimes`, `toHaveBeenCalledWith`: Matchers for verifying mock function behavior.\n\nAll matchers can be negated with the `not` modifier.\n\nMultiple assertions can be chained together.\n\nExtend the `expect` function to add additional custom matchers to increment testing flexibility.\n\n```js\nimport { describe, it, expect } from 'https://unpkg.com/testamenta';\n\nexpect.extend(({ toBeNumber }) =\u003e ({\n  toBeEven: value =\u003e toBeNumber(value) \u0026\u0026 value % 2 === 0,\n}));\n\nawait describe('Custom matchers', () =\u003e {\n  it('should assert even numbers', () =\u003e {\n    expect(2).toBeEven();\n    expect(3).not.toBeEven();\n  });\n});\n```\n\n## Development\n\nTo run in Node, execute `npm run dev`. Test suite will run in terminal in watch mode and will update on each change.\n\nTo run in browser, start a [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) in VSCode.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkusand%2Ftestamenta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkusand%2Ftestamenta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkusand%2Ftestamenta/lists"}