{"id":15015717,"url":"https://github.com/emberjs/ember-mocha","last_synced_at":"2025-04-04T19:15:10.889Z","repository":{"id":20965265,"uuid":"24254047","full_name":"emberjs/ember-mocha","owner":"emberjs","description":"Mocha helpers for testing Ember.js applications","archived":false,"fork":false,"pushed_at":"2023-06-30T18:48:51.000Z","size":2244,"stargazers_count":130,"open_issues_count":49,"forks_count":69,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T15:44:47.291Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emberjs.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}},"created_at":"2014-09-20T04:50:35.000Z","updated_at":"2024-06-27T09:54:26.000Z","dependencies_parsed_at":"2024-02-23T06:45:53.621Z","dependency_job_id":null,"html_url":"https://github.com/emberjs/ember-mocha","commit_stats":{"total_commits":562,"total_committers":34,"mean_commits":"16.529411764705884","dds":0.6761565836298933,"last_synced_commit":"e2a81aff76c03cac1a4ac86d5302a635852bf1e9"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emberjs%2Fember-mocha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emberjs%2Fember-mocha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emberjs%2Fember-mocha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emberjs%2Fember-mocha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emberjs","download_url":"https://codeload.github.com/emberjs/ember-mocha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246953271,"owners_count":20860012,"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-09-24T19:47:50.082Z","updated_at":"2025-04-04T19:15:10.868Z","avatar_url":"https://github.com/emberjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"DEPRECATION WARNING\n===================\n\nThis package is not actively developed. [ember-qunit](https://github.com/emberjs/ember-qunit) is a good alternative. \n\nIf you use ember-mocha and want to maintain it, please ask in the #help channel on the ember discord.\n\nember-mocha\n==============================================================================\n\n[![Latest NPM release][npm-badge]][npm-badge-url]\n[![TravisCI Build Status][travis-badge]][travis-badge-url]\n\n[npm-badge]: https://img.shields.io/npm/v/ember-mocha.svg\n[npm-badge-url]: https://www.npmjs.com/package/ember-mocha\n[travis-badge]: https://img.shields.io/travis/emberjs/ember-mocha/master.svg\n[travis-badge-url]: https://travis-ci.org/emberjs/ember-mocha\n\nember-mocha simplifies testing of Ember applications with\n[Mocha](https://mochajs.org/) by providing Mocha-specific wrappers around the\nhelpers contained in\n[@ember/test-helpers](https://github.com/emberjs/ember-test-helpers).\n\n*Upgrading from an earlier version? Have a look at our\n[Migration Guide](docs/migration.md).*\n\n\nCompatibility\n------------------------------------------------------------------------------\n\n- Ember.js v3.4 or above\n- Ember CLI v2.13 or above\n- Node.js 8 or above\n\n\nInstallation\n------------------------------------------------------------------------------\n\n`ember-mocha` is an [Ember CLI](http://www.ember-cli.com/) addon, so install it\nas you would any other addon:\n\n```sh\n$ ember install ember-mocha\n```\n\nSome other addons are detecting the test framework based on the installed\naddon names and are expecting `ember-cli-mocha` instead. If you have issues\nwith this then `ember install ember-cli-mocha`, which should work exactly\nthe same.\n\n\nUsage\n------------------------------------------------------------------------------\n\nThe following section describes the use of Ember Mocha with the latest modern\nEmber testing APIs, as laid out in the RFCs\n[232](https://github.com/emberjs/rfcs/blob/master/text/0232-simplify-qunit-testing-api.md)\nand\n[268](https://github.com/emberjs/rfcs/blob/master/text/0268-acceptance-testing-refactor.md).\n\nFor the older APIs have a look at our [Legacy Guide](docs/legacy.md).\n\n### Setting the Application\n\nYour `tests/test-helper.js` file should look similar to the following, to\ncorrectly setup the application required by `@ember/test-helpers`:\n\n```javascript\nimport Application from '../app';\nimport config from '../config/environment';\nimport { setApplication } from '@ember/test-helpers';\nimport { start } from 'ember-mocha';\n\nsetApplication(Application.create(config.APP));\nstart();\n```\n\nAlso make sure that you have set `ENV.APP.autoboot = false;` for the `test`\nenvironment in your `config/environment.js`.\n\n### Setup Tests\n\nThe `setupTest()` function can be used to setup a unit test for any kind\nof \"module/unit\" of your application that can be looked up in a container.\n\nIt will setup your test context with:\n\n* `this.owner` to interact with Ember's [Dependency Injection](https://guides.emberjs.com/v3.0.0/applications/dependency-injection/)\n  system\n* `this.set()`, `this.setProperties()`, `this.get()`, and `this.getProperties()`\n* `this.pauseTest()` method to allow easy pausing/resuming of tests\n\nFor example, the following is a unit test for the `SidebarController`:\n\n```javascript\nimport { expect } from 'chai';\nimport { describe, it } from 'mocha';\nimport { setupTest } from 'ember-mocha';\n\ndescribe('SidebarController', function() {\n  setupTest();\n\n  // Replace this with your real tests.\n  it('exists', function() {\n    let controller = this.owner.lookup('controller:sidebar');\n    expect(controller).to.be.ok;\n  });\n});\n```\n\nIf you find that test helpers from other addons want you to pass a `hooks`\nobject you can do so like this:\n\n```javascript\nlet hooks = setupTest();\nsetupMirage(hooks);\n```\n\nThis will make sure that in functions passed to `hooks.afterEach()` the\n`this.owner` and other things that `setupTest()` sets up are still available.\nMocha itself runs `afterEach` hooks in a different order than QUnit, which is\nwhy this \"workaround\" is sometimes needed.\n\n\n### Setup Rendering Tests\n\nThe `setupRenderingTest()` function is specifically designed for tests that\nrender arbitrary templates, including components and helpers.\n\nIt will setup your test context the same way as `setupTest()`, and additionally:\n\n* Initializes Ember's renderer to be used with the\n  [Rendering helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#rendering-helpers),\n  specifically `render()`\n* Adds `this.element` to your test context which returns the DOM element\n  representing the wrapper around the elements that were rendered via\n  `render()`\n* sets up the [DOM Interaction Helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#dom-interaction-helpers)\n  from `@ember/test-helpers` (`click()`, `fillIn()`, ...)\n\n```javascript\nimport { expect } from 'chai';\nimport { describe, it } from 'mocha';\nimport { setupRenderingTest } from 'ember-mocha';\nimport { render } from '@ember/test-helpers';\nimport hbs from 'htmlbars-inline-precompile';\n\ndescribe('GravatarImageComponent', function() {\n  setupRenderingTest();\n\n  it('renders', async function() {\n    await render(hbs`{{gravatar-image}}`);\n    expect(this.element.querySelector('img')).to.exist;\n  });\n});\n```\n\n### Setup Application Tests\n\nThe `setupApplicationTest()` function can be used to run tests that interact\nwith the whole application, so in most cases acceptance tests.\n\nOn top of `setupTest()` it will:\n\n* Boot your application instance\n* Set up all the [DOM Interaction Helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#dom-interaction-helpers)\n  (`click()`, `fillIn()`, ...) as well as the [Routing Helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#routing-helpers)\n  (`visit()`, `currentURL()`, ...) from `@ember/test-helpers`\n\n```javascript\nimport { expect } from 'chai';\nimport { describe, it } from 'mocha';\nimport { setupApplicationTest } from 'ember-mocha';\nimport { visit, currentURL } from '@ember/test-helpers';\n\ndescribe('basic acceptance test', function() {\n  setupApplicationTest();\n\n  it('can visit /', async function() {\n    await visit('/');\n    expect(currentURL()).to.equal('/');\n  });\n});\n```\n\nUpgrading\n------------------------------------------------------------------------------\n\nFor instructions how to upgrade your test suite please read our\n[Migration Guide](docs/migration.md).\n\nContributing\n------------------------------------------------------------------------------\n\nContributions are welcome. Please follow the instructions below to install and\ntest this library.\n\n### Installation\n\n```sh\nnpm install\n```\n\n### Testing\n\nIn order to test in the browser:\n\n```sh\nnpm start\n```\n\n... and then visit [http://localhost:4200/tests](http://localhost:4200/tests).\n\nIn order to perform a CI test:\n\n```sh\nnpm test\n```\n\n\nCopyright and License\n------------------------------------------------------------------------------\n\nCopyright 2014 Switchfly\n\nThis product includes software developed at\nSwitchfly (http://www.switchfly.com).\n\nNOTICE: Only our own original work is licensed under the terms of the Apache\nLicense Version 2.0. The licenses of some libraries might impose different\nredistribution or general licensing terms than those stated in the Apache\nLicense. Users and redistributors are hereby requested to verify these\nconditions and agree upon them.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femberjs%2Fember-mocha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femberjs%2Fember-mocha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femberjs%2Fember-mocha/lists"}