Git Product home page Git Product logo

ember-qunit-nice-errors's Introduction

ember-qunit-nice-errors

Build Status

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:

import { module, test } from 'qunit';

module('Unit | ok test');

test('it works', function(assert) {
  assert.ok(1===3);
});

Test failed output without addon

But with ember-qunit-nice-errors the message is way nicer! Test failed output with addon

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:

ENV['ember-qunit-nice-errors'] = {
  showFileInfo: true
};
Before
assert.ok(false)
After
assert.ok(false) at my-app/tests/unit/ok-test.js:17:2

Also note you can enable this only for certain environments:

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:

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 ilustrates what is the result of using the option completeExistingMessages.

Before
assert.ok(1 === 1, 'one should be one');
After
assert.ok(1 === 1, "assert.ok(1 === 1, 'one should be one')");

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

Credits

We got inspiration from

License

ember-qunit-nice-errors is licensed under the MIT license.

See LICENSE for the full license text.

ember-qunit-nice-errors's People

Contributors

acostami avatar ember-tomster avatar fedekau avatar marpo60 avatar panthony avatar san650 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.