<NME> README.md
<BEF> 
ember-mocha
==============================================================================

[![Latest NPM release][npm-badge]][npm-badge-url]
[![TravisCI Build Status][travis-badge]][travis-badge-url]

[npm-badge]: https://img.shields.io/npm/v/ember-mocha.svg
[npm-badge-url]: https://www.npmjs.com/package/ember-mocha
[travis-badge]: https://img.shields.io/travis/emberjs/ember-mocha/master.svg
[travis-badge-url]: https://travis-ci.org/emberjs/ember-mocha

ember-mocha simplifies testing of Ember applications with
[Mocha](https://mochajs.org/) by providing Mocha-specific wrappers around the
helpers contained in
[@ember/test-helpers](https://github.com/emberjs/ember-test-helpers).

*Upgrading from an earlier version? Have a look at our
[Migration Guide](docs/migration.md).*


Compatibility
------------------------------------------------------------------------------

- Ember.js v3.4 or above
- Ember CLI v2.13 or above
- Node.js 8 or above


Installation
------------------------------------------------------------------------------

`ember-mocha` is an [Ember CLI](http://www.ember-cli.com/) addon, so install it
as you would any other addon:

```sh
$ ember install ember-mocha
```

Some other addons are detecting the test framework based on the installed
addon names and are expecting `ember-cli-mocha` instead. If you have issues

### Test Modules

The `describeModule` helper can be used to declare a module that can be used
to test any "unit" of your application that can be looked up in a container.

For example, the following is a unit test for the `SidebarController`:

```javascript
import {
  describeModule,
  it
} from 'ember-mocha';

describeModule(
  'controller:sidebar',
  'SidebarController',
  {
    // Specify the other units that are required for this test.
    // needs: ['controller:foo']
  },
  function() {
    // Replace this with your real tests.
    it('exists', function() {
      var controller = this.subject();
      expect(controller).to.be.ok;
    });
  }
);

```

start();
be used to look up this controller in the isolated container that will be
created for this test.

The title, `'SidebarController'`, will appear in the test runner and is not
strictly necessary. It defaults to the subject if omitted.

#### Component Test Modules

The `describeComponent` helper extends `describeModule` and provides
additional `render` and `$` helpers within a test's context.

```javascript
import {
  describeComponent,
  it
} from 'ember-mocha';

describeComponent(
  'gravatar-image',
  'GravatarImageComponent',
  {
    // specify the other units that are required for this test
    // needs: ['component:foo', 'helper:bar']
  },
  function() {
    it('renders', function() {
      // creates the component instance
      var component = this.subject();
      expect(component._state).to.equal('preRender');

      // renders the component on the page
      this.render();
      expect(component._state).to.equal('inDOM');
    });
  }
);
```

#### Model Test Modules

The `describeModel` helper also extends `describeModule` and provides an
additional `store` helper within a test's context.

```javascript
import {
  describeModel,
  it
} from 'ember-mocha';

describeModel(
  'contact',
  'Contact',
  {
    // Specify the other units that are required for this test.
      needs: []
  },
  function() {
    // Replace this with your real tests.
    it('exists', function() {
      var model = this.subject();
      // var store = this.store();
      expect(model).to.be.ok;
    });
  }
);
```

### Asynchronous Testing

* Initializes Ember's renderer to be used with the
  [Rendering helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#rendering-helpers),
  specifically `render()`
* Adds `this.element` to your test context which returns the DOM element
  representing the wrapper around the elements that were rendered via
  `render()`
* sets up the [DOM Interaction Helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#dom-interaction-helpers)
  from `@ember/test-helpers` (`click()`, `fillIn()`, ...)

```javascript
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { setupRenderingTest } from 'ember-mocha';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

describe('GravatarImageComponent', function() {
  setupRenderingTest();

  it('renders', async function() {
    await render(hbs`{{gravatar-image}}`);
    expect(this.element.querySelector('img')).to.exist;
  });
});
```

### Setup Application Tests

The `setupApplicationTest()` function can be used to run tests that interact
with the whole application, so in most cases acceptance tests.

On top of `setupTest()` it will:

* Boot your application instance
* Set up all the [DOM Interaction Helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#dom-interaction-helpers)
  (`click()`, `fillIn()`, ...) as well as the [Routing Helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#routing-helpers)
  (`visit()`, `currentURL()`, ...) from `@ember/test-helpers`

```javascript
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { setupApplicationTest } from 'ember-mocha';
import { visit, currentURL } from '@ember/test-helpers';

describe('basic acceptance test', function() {
  setupApplicationTest();

  it('can visit /', async function() {
    await visit('/');
    expect(currentURL()).to.equal('/');
  });
});
```

Upgrading
------------------------------------------------------------------------------

For instructions how to upgrade your test suite please read our
[Migration Guide](docs/migration.md).

Contributing
------------------------------------------------------------------------------

Contributions are welcome. Please follow the instructions below to install and
test this library.

### Installation

```sh
npm install
```

### Testing

In order to test in the browser:

```sh
npm start
```

... and then visit [http://localhost:4200/tests](http://localhost:4200/tests).

In order to perform a CI test:

```sh
npm test
```


Copyright and License
------------------------------------------------------------------------------

Copyright 2014 Switchfly

This product includes software developed at
Switchfly (http://www.switchfly.com).

NOTICE: Only our own original work is licensed under the terms of the Apache
License Version 2.0. The licenses of some libraries might impose different
redistribution or general licensing terms than those stated in the Apache
License. Users and redistributors are hereby requested to verify these
conditions and agree upon them.

<MSG> Update README with new API functions

<DFF> @@ -42,32 +42,27 @@ call `setResolver` in the `beforeSetup` callback of your test modules.
 
 ### Test Modules
 
-The `describeModule` helper can be used to declare a module that can be used
-to test any "unit" of your application that can be looked up in a container.
+The `setupModuleTest` function can be used to setup a unit test for any kind
+of "module/unit" of your application that can be looked up in a container.
 
 For example, the following is a unit test for the `SidebarController`:
 
 ```javascript
-import {
-  describeModule,
-  it
-} from 'ember-mocha';
-
-describeModule(
-  'controller:sidebar',
-  'SidebarController',
-  {
+import { describe, it } from 'mocha';
+import { setupModuleTest } from 'ember-mocha';
+
+describe('SidebarController', function() {
+  setupModuleTest('controller:sidebar', {
     // Specify the other units that are required for this test.
     // needs: ['controller:foo']
-  },
-  function() {
-    // Replace this with your real tests.
-    it('exists', function() {
-      var controller = this.subject();
-      expect(controller).to.be.ok;
-    });
-  }
-);
+  });
+  
+  // Replace this with your real tests.
+  it('exists', function() {
+    var controller = this.subject();
+    expect(controller).to.be.ok;
+  });
+});
 
 ```
 
@@ -75,68 +70,55 @@ The subject is specified as `controller:sidebar`, which is the key that will
 be used to look up this controller in the isolated container that will be
 created for this test.
 
-The title, `'SidebarController'`, will appear in the test runner and is not
-strictly necessary. It defaults to the subject if omitted.
-
 #### Component Test Modules
 
-The `describeComponent` helper extends `describeModule` and provides
-additional `render` and `$` helpers within a test's context.
+The `setupComponentTest` function is specifically designed to test components
+and provides additional `render` and `$` helpers within a test's context.
 
 ```javascript
-import {
-  describeComponent,
-  it
-} from 'ember-mocha';
-
-describeComponent(
-  'gravatar-image',
-  'GravatarImageComponent',
-  {
+import { describe, it } from 'mocha';
+import { setupComponentTest } from 'ember-mocha';
+
+describe('GravatarImageComponent', function() {
+  setupComponentTest('gravatar-image', {
     // specify the other units that are required for this test
     // needs: ['component:foo', 'helper:bar']
-  },
-  function() {
-    it('renders', function() {
-      // creates the component instance
-      var component = this.subject();
-      expect(component._state).to.equal('preRender');
-
-      // renders the component on the page
-      this.render();
-      expect(component._state).to.equal('inDOM');
-    });
-  }
-);
+  });
+
+  it('renders', function() {
+    // creates the component instance
+    var component = this.subject();
+    expect(component._state).to.equal('preRender');
+
+    // renders the component on the page
+    this.render();
+    expect(component._state).to.equal('inDOM');
+  });
+});
 ```
 
 #### Model Test Modules
 
-The `describeModel` helper also extends `describeModule` and provides an
-additional `store` helper within a test's context.
+The `setupModelTest` function can be used to test Ember Data models and
+provides an additional `store` helper within a test's context.
 
 ```javascript
-import {
-  describeModel,
-  it
-} from 'ember-mocha';
-
-describeModel(
-  'contact',
-  'Contact',
-  {
+import { describe, it } from 'mocha';
+import { setupModelTest } from 'ember-mocha';
+
+describe('Contact', function() {
+  setupModelTest('contact', {
     // Specify the other units that are required for this test.
-      needs: []
-  },
-  function() {
-    // Replace this with your real tests.
-    it('exists', function() {
-      var model = this.subject();
-      // var store = this.store();
-      expect(model).to.be.ok;
-    });
-  }
-);
+    needs: []
+  });
+  
+  // Replace this with your real tests.
+  it('exists', function() {
+    var model = this.subject();
+    // var store = this.store();
+    expect(model).to.be.ok;
+  });
+});
 ```
 
 ### Asynchronous Testing

Update README with new API functions