{"id":13482923,"url":"https://github.com/bitovi/funcunit","last_synced_at":"2025-04-08T01:36:06.321Z","repository":{"id":811919,"uuid":"519869","full_name":"bitovi/funcunit","owner":"bitovi","description":"A functional test suite based on jQuery","archived":false,"fork":false,"pushed_at":"2021-04-01T21:06:52.000Z","size":33526,"stargazers_count":571,"open_issues_count":64,"forks_count":381,"subscribers_count":73,"default_branch":"master","last_synced_at":"2024-04-14T22:37:31.777Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://funcunit.com/","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/bitovi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-02-16T04:56:06.000Z","updated_at":"2024-03-01T12:18:35.000Z","dependencies_parsed_at":"2022-08-16T11:00:21.157Z","dependency_job_id":null,"html_url":"https://github.com/bitovi/funcunit","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitovi%2Ffuncunit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitovi%2Ffuncunit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitovi%2Ffuncunit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitovi%2Ffuncunit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitovi","download_url":"https://codeload.github.com/bitovi/funcunit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247761051,"owners_count":20991531,"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-07-31T17:01:06.745Z","updated_at":"2025-04-08T01:36:06.303Z","avatar_url":"https://github.com/bitovi.png","language":"JavaScript","funding_links":[],"categories":["Tools and frameworks","Tools and frameworks (a-z↓)"],"sub_categories":[],"readme":"\u003c!--\n@hide title\n\n@constructor FuncUnit\n@group actions Actions\n@group css CSS\n@group dimensions Dimensions\n@group manipulation Manipulation\n@group traversal Traversal\n@group waits Waits\n@group utilities Utilities\n\n--\u003e\n# FuncUnit\n\n[![Build Status](https://travis-ci.org/bitovi/funcunit.svg?branch=master)](https://travis-ci.org/bitovi/funcunit)\n[![npm version](https://badge.fury.io/js/funcunit.svg)](https://badge.fury.io/js/funcunit)\n[![Join our Slack](https://img.shields.io/badge/slack-join%20chat-611f69.svg)](https://www.bitovi.com/community/slack?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\u003e Write better tests, faster.\n\n*Note:* [FuncUnit Roadmap](http://forum.javascriptmvc.com/#Topic/32525000001436023)\n\nThe [FuncUnit Getting Started](http://funcunit.com/guides/Guides.guides.start.html) guide is a quick walkthrough of creating and running a test.\n\n## Set up a test\n\n[QUnit](http://docs.jquery.com/Qunit) provides the basic structure needed to write unit or functional tests.\n\n### Module\n\n[Modules](http://docs.jquery.com/QUnit/module#namelifecycle) are groups of tests with setup and teardown methods that run for each test.\n\n```js\nmodule(\"Contacts\", {\n  // runs before each test\n  setup: function(){\n    // setup code\n  },\n  // runs after each test\n  teardown: function(){\n    // cleanup code\n  }\n});\n```\n\n### Test\n\n```js\ntest(\"findOne\", function(){\n  // define a test\n});\n```\n\n### Assertions\n\n```js\ntest(\"counter\", function() {\n  ok(Conctacts.first().name, \"there is a name property\");\n  equal(Contacts.counter(), 5, \"there are 5 contacts\");\n});\n```\n\n## Open a page\n\nThe following uses `F.open( URL )` to open autocomplete.html before every test.\n\n```js\nmodule(\"autosuggest\", {\n  setup: function() {\n    F.open('autosuggest.html');\n  }\n});\n```\n\nCalling open on window will cause FuncUnit commands to operate on the current window.  This is also the default if you don't open any page.\n\n\n## Query for elements\n\nFuncUnit tests are written just like jQuery. [`F`](http://funcunit.com/guides/funcunit.finding.html) is a copy of the `$` method. It is used to find elements in the page you're testing. Like `$`, FuncUnit methods are chainable on the results of `F`.\n\n```js\n// grab the #description element, wait for it to be visible, type in it\nF(\"#description\").visible().type(\"Test Framework\");\n```\n\n## Simulate user actions\n\nWhen you're testing a widget, you need to simulate the [actions](http://funcunit.com/guides/Guides.actions.html) that user takes.  FuncUnit uses the\n[syn library](https://github.com/bitovi/syn) to accurately simulate the correct low level events like _mouseup_ and _keypress_ for high\nlevel actions like [click()](http://funcunit.com/docs/FuncUnit.prototype.click.html) and [type()](http://funcunit.com/docs/FuncUnit.prototype.type.html).  The following shows how to simulate common user actions.\n\n### Click\n\n```js\n// click a button\nF('#submit_button').click();\n```\n\n### Type\n\n```js\n// type in an input\nF('#task_name').type(\"Learn FuncUnit\");\n```\n\n### Drag\n\n```js\n// drag a task item to the trash area\nF('.task').drag(\".trash\");\n```\n\n## Wait for page conditions\n\nAfter a user action, your test page's event handlers run and the page is changed.\nWait commands are used to wait for some page condition before continuing.\n\nWaits are overloaded jQuery getter methods.  `F.fn.text( textVal, callback )`\nwaits for an element's `$.fn.text` to match the `textVal`.\n\n```js\n// wait for result to show \"task complete\"\nF(\"#result\").text(\"task complete\");\n```\n\n### Visible\n\n```js\n// wait for first result to be visible\nF('#autocomplete_results:first-child').visible();\n```\n\n### Width\n\n```js\n// after clicking a menu item, wait for its width to be 200px\nF('#horizontal_menu_item').width(200);\n```\n\n### Val\n\n```js\n// wait for the input value\nF('#language_input').val(\"JavaScript\");\n```\n\n### Size\n\n```js\n// wait for number of matched elements\nF('.contact').size(5);\n```\n\nThere are many more [waits](http://funcunit.com/guides/Guides.waits.html) possible.\n\n\n\u003ch2 id=\"get\"\u003eGet information and run assertions\u003c/h2\u003e\n\nAfter simulating an action and waiting for the page to change, you often want to get information\nabout an element and run assertions.  You can use jQuery getter methods in combination with QUnit assertions.\n\nThese methods (which return synchronous results) are used in callbacks that run after a wait method completes.\n\n```js\n// wait until we have some results, then call the callback\nF('.autocomplete_item').visible(function(){\n  equal( F('.autocomplete_item').size(), 5, \"there are 5 results\");\n});\n```\n\n\u003ch2 id=\"browser\"\u003eRunning in browser\u003c/h2\u003e\n\nThese tests can be loaded in any browser.  The app page opens in a separate window and results show up in the QUnit page.\n\n```js\ntest(\"JavaScript results\", function(){\n  F('input').click().type(\"JavaScript\");\n\n  // wait until we have some results\n  F('.autocomplete_item').visible(function(){\n    equal( F('.autocomplete_item').size(), 5, \"there are 5 results\");\n  });\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitovi%2Ffuncunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitovi%2Ffuncunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitovi%2Ffuncunit/lists"}