https://github.com/adopted-ember-addons/ember-qunit-nice-errors
Because expected true, result false is not enough!
https://github.com/adopted-ember-addons/ember-qunit-nice-errors
Last synced: 6 months ago
JSON representation
Because expected true, result false is not enough!
- Host: GitHub
- URL: https://github.com/adopted-ember-addons/ember-qunit-nice-errors
- Owner: adopted-ember-addons
- License: mit
- Created: 2016-05-13T11:56:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-11-15T16:28:51.000Z (almost 3 years ago)
- Last Synced: 2025-03-07T12:33:56.918Z (7 months ago)
- Language: JavaScript
- Homepage: http://wyeworks.github.io/ember-qunit-nice-errors/
- Size: 1.15 MB
- Stars: 56
- Watchers: 22
- Forks: 12
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ember-qunit-nice-errors
[](https://travis-ci.org/wyeworks/ember-qunit-nice-errors)Because expected true, result false is not enough!
This addon aims to improve the testing experience by defining a nice
message on those asserts that don't have one set by you.## Installation
As easy as `ember install ember-qunit-nice-errors`
## Example
When you have a test with a failing assertion and no custom message, the default error doesn't say much.
As you can see by the following example test and the default ouput below:```js
import { module, test } from 'qunit';module('Unit | ok test');
test('it works', function(assert) {
assert.ok(1===3);
});
```
But with **ember-qunit-nice-errors** the message is way nicer!
## Configuration
### showFileInfo
If you want your error messages to include the original test file, line and column where the failed assertion is, just add the following configuration on your `config/environment.js` file:
```js
ENV['ember-qunit-nice-errors'] = {
showFileInfo: true
};
```##### Before
```js
assert.ok(false)
```##### After
```js
assert.ok(false) at my-app/tests/unit/ok-test.js:17:2
```Also note you can enable this only for certain environments:
```js
if (environment === 'development') {
ENV['ember-qunit-nice-errors'] = {
showFileInfo: true
};
}
```### completeExistingMessages
If you fully trust us you can add this option to replace all assertions within your project tests, just add this to your configuration on your `config/environment.js` file:
```js
ENV['ember-qunit-nice-errors'] = {
completeExistingMessages: true
};
```Don't worry, the override will still show your orginal messages, it is not a destructive operation!
The following example illustrates what is the result of using the option `completeExistingMessages`.
##### Before
```js
assert.ok(1 === 1, 'one should be one');
```##### After
```js
assert.ok(1 === 1, "assert.ok(1 === 1, 'one should be one')");
```### include
By default only test files that match the glob `**/*-test.js` are processed by the
addon. You can include/exclude files from being processed by setting custom glob
rules.```js
ENV['ember-qunit-nice-errors'] = {
include: ["**/*-foo.js"]
};
```Note that by changing the `include` configuration you are overriding the default
glob `**/*-test.js`. If you want to include files and keep the default rules,
you can write it as follows.```js
ENV['ember-qunit-nice-errors'] = {
include: [
"**/*-test.js",
"**/*-foo.js",
]
};
```You can use any expression supported by `minimatch`, see https://www.npmjs.com/package/minimatch for more info.
### exclude
You can exclude specific test files from beign processed by adding exclude
rules.```js
ENV['ember-qunit-nice-errors'] = {
exclude: ["**/my-special-test.js"]
};
```You can use any expression supported by `minimatch`, see https://www.npmjs.com/package/minimatch for more info.
## Supported assertions
We are currently supporting all the assertions provided by QUnit, those are:
* `ok`
* `notOk`
* `equal`
* `notEqual`
* `deepEqual`
* `notDeepEqual`
* `propEqual`
* `notPropEqual`
* `strictEqual`
* `notStrictEqual`## Maintainers
- Diego Acosta ([@acostami](https://github.com/acostami))
- Federico Kauffman ([@fedekau](https://github.com/fedekau))
- Samanta de Barros ([@sdebarros](https://github.com/sdebarros))
- Santiago Ferreira ([@san650](https://github.com/san650))## Credits
We got inspiration from
- [qunit-helpful](https://github.com/bahmutov/qunit-helpful)
- [ember-watson](https://github.com/abuiles/ember-watson)## License
ember-qunit-nice-errors is licensed under the MIT license.
See [LICENSE](./LICENSE.md) for the full license text.