{"id":16844787,"url":"https://github.com/stephanhoyer/mithril-test","last_synced_at":"2025-04-11T06:06:51.709Z","repository":{"id":66695850,"uuid":"126547000","full_name":"StephanHoyer/mithril-test","owner":"StephanHoyer","description":"test your mithril modules in a real browser","archived":false,"fork":false,"pushed_at":"2023-12-15T11:34:14.000Z","size":9,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-03T16:54:56.244Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StephanHoyer.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}},"created_at":"2018-03-23T23:01:54.000Z","updated_at":"2018-03-26T06:58:29.000Z","dependencies_parsed_at":"2023-04-14T06:09:15.679Z","dependency_job_id":null,"html_url":"https://github.com/StephanHoyer/mithril-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanHoyer%2Fmithril-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanHoyer%2Fmithril-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanHoyer%2Fmithril-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanHoyer%2Fmithril-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StephanHoyer","download_url":"https://codeload.github.com/StephanHoyer/mithril-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239554769,"owners_count":19658278,"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":"2024-10-13T12:56:37.470Z","updated_at":"2025-02-18T21:32:54.572Z","avatar_url":"https://github.com/StephanHoyer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mithril-test\ntest your mithril modules in a real browser\n\n[![Build Status](https://travis-ci.org/StephanHoyer/mithril-test.svg?branch=master)](https://travis-ci.org/StephanHoyer/mithril-test)\n\n## Example usage\n\nLet's say you have the following component:\n```js\n// myModule.js\nconst m = require('mithril')\n\nmodule.exports = {\n  showParagraph: true,\n  inputValue: '',\n  view: ({ state }) =\u003e [\n    m('button', {\n      onclick: () =\u003e {\n        state.showParagraph = false\n        setTimeout(() =\u003e {\n          state.showParagraph = true\n          m.redraw()\n        }, 10)\n      },\n    }),\n    m('input', { oninput: e =\u003e (state.inputValue = e.target.value) }),\n    m('div', state.inputValue),\n    state.showParagraph \u0026\u0026 m('p', 'my paragraph'),\n  ],\n}\n```\n\n... you can test its functionality like this:\n\n```js\n// myModule.test.js\nconst load = require('mithril-test')\n\ndescribe('myModule', () =\u003e {\n  it('should work', () =\u003e {\n    return load('./myModule')\n      .shouldHave('p')\n      .shouldHave(1, 'p')\n      .shouldNotHave(2, 'p')\n      .shouldNotHave('h3')\n      .shouldNotContain('fancy stuff')\n      .setValue('input', 'fancy stuff')\n      .shouldContain('fancy stuff')\n      .waitFor(100)\n      .click('button')\n      .shouldNotHave('p')\n      .waitFor('p')\n      .shouldHave('p')\n      .run()\n  })\n})\n```\n\nWhole test takes about 600ms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanhoyer%2Fmithril-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephanhoyer%2Fmithril-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanhoyer%2Fmithril-test/lists"}