<commit_before># jasmine

Easily write and run Jasmine client and server unit and integration tests.
You can use all [Jasmine 2.0 features](http://jasmine.github.io/2.0/introduction.html).

### Installation

```bash
meteor add sanjo:jasmine
meteor add velocity:html-reporter@0.3.0-rc.3
```

### Examples and Tutorials

* [Integration and Unit tests for a refactored version of the Leaderboard example (by <NAME>)](https://github.com/meteor-velocity/velocity-example/tree/jasmine-only/tests/jasmine/).
* [Comprehensive tutorial about testing all common aspects of a Meteor app (by <NAME>)](http://doctorllama.wordpress.com/2014/09/22/bullet-proof-internationalised-meteor-applications-with-velocity-unit-testing-integration-testing-and-jasmine/)

### Testing modes

Each testing mode has different characteristics. Each testing mode has an own folder.

#### Server

##### Server Unit Test Mode

* You can unit test server app code.
* The tests run isolated from your app.
* The Meteor API and all packages are stubbed in this mode.
* Place your server unit tests in the folder `tests/jasmine/server/unit/` or a subfolder of it.

##### Server Integration Test Mode

Not available yet. Will be added in the near future.

#### Client

##### Client Unit Test Mode

* You can test client code.
* The tests are executed directly inside the browser.
* Nothing is automatically stubbed.
* Place your client unit tests in the folder `tests/jasmine/client/unit/` or a subfolder of it.

> __Note:__ Tests currently only run in Google Chrome. If you need support for another Browser please [open an issue](https://github.com/Sanjo/meteor-jasmine/issues/new).

##### Client Integration Test Mode

* You can test client code.
* The tests are executed directly inside the browser in a copy of your app.
* Nothing is automatically stubbed.
* Place your client integration tests in the folder `tests/jasmine/client/integration/` or a subfolder of it.

> __Tip:__ Use this mode when you want to test the communication between client and server.
> In other cases you should probably use the Client Unit Test mode.

### Stubs

Files in `tests/jasmine` folder (or a subfolder of it) that end with `-stubs.js` or `-stub.js` are treated as stubs and are loaded before the app code.

### Mocks

#### Mocking Meteor

This package ships with mocks for the Meteor API. You can mock the Meteor API in your tests with:

```javascript
beforeEach(function () {
  MeteorStubs.install();
});

afterEach(function () {
  MeteorStubs.uninstall();
});
```

This is done automatically for server unit tests.
You need to do it yourself for your client tests if you want to write
unit tests that run in the browser.

#### Mocking objects

You can mock any object with the global helper function `mock`.
This will avoid unwanted side effects that can affect other tests.
Here is an example how to mock the Players collection of the Leaderboard example:

```javascript
beforeEach(function () {
  mock(window, 'Players');
});
```

This will mock the Players collection for each test.
The original Players collection is automatically restored after each test.

#### Creating more complex mocks

You can also create mocks manually. I would suggest to use the following pattern:

Create a mock service with a method `install` and `uninstall` ([example for Meteor](https://github.com/alanning/meteor-stubs/blob/master/index.js))

  * install: Saves the original object and mocks it
  * uninstall: Restores the original object
  
This pattern allows you to enable mocks only for specific tests and have a clean and independent mock for each test.

### For sanjo:jasmine maintainers

#### Testing

We use spacejamio:munit with the BDD style for testing sanjo:jasmine.

##### Running package unit tests

```bash
cd test-app
meteor test-packages sanjo:jasmine
```

#### Publish a new version

1. Increase the version in `package.js` (follow [Semantic Versioning conventions](http://semver.org/))
2. `meteor publish`
3. Commit "Bump to version X.X.X"
4. Create a tag with the version "X.X.X"
5. Push

### Copyright

The code is licensed under the MIT License (see LICENSE file). 

The boot.js scripts are based on code that is part of Jasmine 2.0 ([LICENSE](https://github.com/pivotal/jasmine/blob/v2.0.0/MIT.LICENSE)).
<commit_msg>Moves maintenance info out of README<commit_after># jasmine

Easily write and run Jasmine client and server unit and integration tests.
You can use all [Jasmine 2.0 features](http://jasmine.github.io/2.0/introduction.html).

### Installation

```bash
meteor add sanjo:jasmine
meteor add velocity:html-reporter@0.3.0-rc.3
```

### Examples and Tutorials

* [Integration and Unit tests for a refactored version of the Leaderboard example (by <NAME>)](https://github.com/meteor-velocity/velocity-example/tree/jasmine-only/tests/jasmine/).
* [Comprehensive tutorial about testing all common aspects of a Meteor app (by <NAME>)](http://doctorllama.wordpress.com/2014/09/22/bullet-proof-internationalised-meteor-applications-with-velocity-unit-testing-integration-testing-and-jasmine/)

### Testing modes

Each testing mode has different characteristics. Each testing mode has an own folder.

#### Server

##### Server Unit Test Mode

* You can unit test server app code.
* The tests run isolated from your app.
* The Meteor API and all packages are stubbed in this mode.
* Place your server unit tests in the folder `tests/jasmine/server/unit/` or a subfolder of it.

##### Server Integration Test Mode

Not available yet. Will be added in the near future.

#### Client

##### Client Unit Test Mode

* You can test client code.
* The tests are executed directly inside the browser.
* Nothing is automatically stubbed.
* Place your client unit tests in the folder `tests/jasmine/client/unit/` or a subfolder of it.

> __Note:__ Tests currently only run in Google Chrome. If you need support for another Browser please [open an issue](https://github.com/Sanjo/meteor-jasmine/issues/new).

##### Client Integration Test Mode

* You can test client code.
* The tests are executed directly inside the browser in a copy of your app.
* Nothing is automatically stubbed.
* Place your client integration tests in the folder `tests/jasmine/client/integration/` or a subfolder of it.

> __Tip:__ Use this mode when you want to test the communication between client and server.
> In other cases you should probably use the Client Unit Test mode.

### Stubs

Files in `tests/jasmine` folder (or a subfolder of it) that end with `-stubs.js` or `-stub.js` are treated as stubs and are loaded before the app code.

### Mocks

#### Mocking Meteor

This package ships with mocks for the Meteor API. You can mock the Meteor API in your tests with:

```javascript
beforeEach(function () {
  MeteorStubs.install();
});

afterEach(function () {
  MeteorStubs.uninstall();
});
```

This is done automatically for server unit tests.
You need to do it yourself for your client tests if you want to write
unit tests that run in the browser.

#### Mocking objects

You can mock any object with the global helper function `mock`.
This will avoid unwanted side effects that can affect other tests.
Here is an example how to mock the Players collection of the Leaderboard example:

```javascript
beforeEach(function () {
  mock(window, 'Players');
});
```

This will mock the Players collection for each test.
The original Players collection is automatically restored after each test.

#### Creating more complex mocks

You can also create mocks manually. I would suggest to use the following pattern:

Create a mock service with a method `install` and `uninstall` ([example for Meteor](https://github.com/alanning/meteor-stubs/blob/master/index.js))

  * install: Saves the original object and mocks it
  * uninstall: Restores the original object
  
This pattern allows you to enable mocks only for specific tests and have a clean and independent mock for each test.

### Copyright

The code is licensed under the MIT License (see LICENSE file). 

The boot.js scripts are based on code that is part of Jasmine 2.0 ([LICENSE](https://github.com/pivotal/jasmine/blob/v2.0.0/MIT.LICENSE)).

{'fraction_non_alphanumeric': 0.09050664043285785, 'fraction_numerical': 0.005779636005902607, 'mean_word_length': 4.294921875, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '842014', 'n_tokens_mistral': 2377, 'n_tokens_neox': 2221, 'n_words': 1044}