{"id":13747455,"url":"https://github.com/fnando/test_squad","last_synced_at":"2025-05-09T08:32:44.897Z","repository":{"id":26700195,"uuid":"30157245","full_name":"fnando/test_squad","owner":"fnando","description":"Running JavaScript tests on your Rails app, the easy way.","archived":true,"fork":false,"pushed_at":"2016-07-01T03:12:19.000Z","size":325,"stargazers_count":55,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-05T01:17:45.975Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/fnando.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-01T19:42:18.000Z","updated_at":"2024-02-05T10:54:20.000Z","dependencies_parsed_at":"2022-08-19T18:31:39.666Z","dependency_job_id":null,"html_url":"https://github.com/fnando/test_squad","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Ftest_squad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Ftest_squad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Ftest_squad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Ftest_squad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnando","download_url":"https://codeload.github.com/fnando/test_squad/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253217220,"owners_count":21873043,"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-08-03T06:01:29.707Z","updated_at":"2025-05-09T08:32:44.568Z","avatar_url":"https://github.com/fnando.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# TestSquad\n\n[![Travis-CI](https://travis-ci.org/fnando/test_squad.png)](https://travis-ci.org/fnando/test_squad)\n[![Code Climate](https://codeclimate.com/github/fnando/test_squad/badges/gpa.svg)](https://codeclimate.com/github/fnando/test_squad)\n[![Test Coverage](https://codeclimate.com/github/fnando/test_squad/badges/coverage.svg)](https://codeclimate.com/github/fnando/test_squad/coverage)\n[![Gem](https://img.shields.io/gem/v/test_squad.svg)](https://rubygems.org/gems/test_squad)\n[![Gem](https://img.shields.io/gem/dt/test_squad.svg)](https://rubygems.org/gems/test_squad)\n\nRunning JavaScript tests on your Rails app, the easy way.\n\n- Supports [QUnit](http://qunitjs.com), [Ember.js](http://emberjs.com), [Mocha](http://mochajs.org) and [Jasmine](http://jasmine.github.io/)\n- Go headless with [Phantom.js](http://phantomjs.org)\n- Colored output\n- Asset pipeline support\n- [Rails Assets](http://rails-assets.org) support (Bower Proxy)\n\n## Installation\n\nAdd these lines to your application's `Gemfile`:\n\n```ruby\ngroup :development, :test do\n  gem \"test_squad\"\nend\n```\n\nAnd then execute:\n\n```console\n$ bundle\n```\n\n## Usage\n\nAfter installing TestSquad, generate your tests skeleton. The generator will detect if you're using RSpec or TestUnit and will generate the `javascript` directory based on that detection. Just use the command `rails generate test_squad:install --framework FRAMEWORK`.\n\n```console\n$ rails generate test_squad:install --framework jasmine\n    create  test/javascript/squad_sample\n    create  test/javascript/squad_sample/.keep\n    create  test/javascript/spec_helper.js\n    source  https://rails-assets.org\n     exist  test/javascript\n    create  test/javascript/test_squad.rb\n```\n\nIf you're already using \u003chttps://rails-assets.org\u003e, you can skip the Gemfile entry with `--skip-source`.\n\n## Running tests\n\nYou can run your tests with `rake test_squad`. You can also visit `http://localhost:3000/tests` for in-browser testing.\n\n![Jasmine](https://github.com/fnando/test_squad/raw/master/screenshots/jasmine.png)\n\n![Mocha](https://github.com/fnando/test_squad/raw/master/screenshots/mocha.png)\n\n![QUnit](https://github.com/fnando/test_squad/raw/master/screenshots/qunit.png)\n\n![Terminal](https://github.com/fnando/test_squad/raw/master/screenshots/terminal.png)\n\n![Ember](https://github.com/fnando/test_squad/raw/master/screenshots/terminal-ember.png)\n\n### Configure Ember\n\nWhen using the Ember framework, you must configure your application name. It'll default to your Rails application name.\n\n```javascript\n//= require application\n//= require_self\n//= require_tree ./components\n//= require_tree ./models\n//= require_tree ./routes\n//= require_tree ./unit\n//= require_tree ./views\n\n// Set the application.\nApp = SquadSample;\n\n// Set up Ember testing.\nApp.rootElement = \"#ember-testing\";\nApp.setupForTesting();\nApp.injectTestHelpers();\n```\n\nTo disable all Ember logging, add the following line to `test_helper.js`, just before the `//= require application` line.\n\n```javascript\n//= require ./logging\n```\n\nThen create the file `spec/javascript/logging.js` with this content:\n\n```javascript\nEmber = {ENV: {\n  LOG_TRANSITIONS: false,\n  LOG_VIEW_LOOKUPS: false,\n  LOG_ACTIVE_GENERATION: false,\n  LOG_RESOLVER: false,\n  LOG_TRANSITIONS: false,\n  LOG_TRANSITIONS_INTERNAL: false,\n  LOG_VERSION: false\n}};\n```\n\n### Configure Mocha\n\nBy default, Mocha is configured with [expect.js](https://github.com/Automattic/expect.js). You can use different libraries like [should.js](https://github.com/visionmedia/should.js) or [chai](http://chaijs.com/).\n\nJust add the dependency to your `Gemfile`. Use `rails-assets-chai` or `rails-assets-should`:\n\n```ruby\nsource \"https://rubygems.org\"\nsource \"https://rails-assets.org\"\n\ngem \"rails\", \"4.2.0\"\ngem \"sass-rails\", \"~\u003e 5.0\"\ngem \"uglifier\", \"\u003e= 1.3.0\"\n\ngem \"ember-rails\"\ngem \"rails-assets-jquery\"\n\ngroup :development, :test do\n  gem \"test_squad\", path: \"../../test_squad\"\n  gem \"rails-assets-mocha\"\n  gem \"rails-assets-chai\"\nend\n```\n\nInstall the dependency with `bundle install`. Then require the library on `{test/spec}/javascript/spec_helper.js`.\n\n```javascript\n//= require application\n//= require chai\n//= require_self\n//= require_tree ./squad_sample\n\nvar assert = chai.assert;\n\nmocha.setup(\"bdd\");\nmocha.checkLeaks();\nmocha.globals([\"jQuery\"]);\nmocha.reporter(mocha.TestSquad);\nwindow.onload = function(){\n  mocha.run();\n};\n```\n\n## Troubleshooting\n\n### Route is not available\n\nIf you have a catch-all route, add the following line to your `config/routes.rb` file. This will be required if you configure Ember.js to use `history.pushState`.\n\n```ruby\nget :tests, to: \"test_squad#tests\" unless Rails.env.production?\n```\n\nOtherwise you won't be able to to run your in-browser tests.\n\n### Using NPM/Bower instead of rails-assets\n\nYou may want to use something else (NPM, Bower directly, etc). In this case, the easiest way is adding QUnit's directory to the load path.\n\nLet's configure QUnit from NPM. Create the file `package.json` like the following:\n\n```json\n{\n  \"name\": \"myapp\",\n  \"version\": \"0.0.0\",\n  \"private\": true\n}\n```\n\nRun the command `npm install qunitjs --save-dev` to install QUnit. The library will be available at `node_modules/qunitjs/qunit`. Now modify `config/initializers/assets.rb`, adding this directory to the load path.\n\n```ruby\n# ...\n\nif Rails.env.development?\n  Rails.application.config.assets \u003c\u003c Rails.root.join(\"node_modules/qunitjs/qunit\").to_s\nend\n```\n\nThat's it!\n\n## Configuration\n\nThe rake task accepts some env variables.\n\n- `TEST_SQUAD_SERVER_HOST`: the binding host. Defaults to `localhost`.\n- `TEST_SQUAD_SERVER_PORT`: the server port. Defaults to `42424`.\n- `TEST_SQUAD_SERVER_PATH`: the server path. Defaults to `/tests`.\n- `TEST_SQUAD_TIMEOUT`: how much time a test can take. Defaults to `10` (seconds).\n- `TEST_SQUAD_PHANTOMJS_BIN`: set the PhantomJS binary. Defaults to `phantomjs`.\n\nYou can configure these options using the `{test,spec}/javascript/test_squad.rb` file.\n\n```ruby\nTestSquad.configure do |config|\n  config.framework = \"qunit\"\n  config.server_host = \"127.0.0.1\"\n  config.server_port = 42424\n  config.server_path = \"/tests\"\n  config.timeout = 10\n  config.phantomjs_bin = \"phantomjs\"\nend\n```\n\n## Contributing\n\nBefore starting, create an issue asking if it'd be a useful/wanted feature. This will avoid wasting your time.\n\n1. Fork it ( http://github.com/fnando/test_squad/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\nRemember:\n\n- Don't mess with versioning.\n- Follow the code style already present.\n- Opening an issue asking if your feature/change will be merged it's recommended, so that you don't waste your time.\n\n## License\n\n(The MIT License)\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Ftest_squad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnando%2Ftest_squad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Ftest_squad/lists"}