Code Monkey home page Code Monkey logo

qunit-assertions-extra's Introduction

qunit-assertions-extra

A Collection of helpful assertions for use with qunit.

assert.contains('Hello there!', 'Hello');
assert.contains([1, 3], 3);

assert.matches('Hello there!', /Hello/);

Installation

yarn add --dev qunit-assertions-extra
npm install --save-dev qunit-assertions-extra

Then, wherever qunit tests are initialized, add

import * as QUnit from 'qunit';
import { setup } from 'qunit-assertions-extra';

setup(QUnit.assert);

This will also enable the tsserver to provide intellisense for assert.

Ember Projects

Requirements: ember-auto-import and add the above import to your tests/test-helper.js file.

Example:

import Application from '../app';
import * as QUnit from 'qunit';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';
import { setup } from 'qunit-assertions-extra';

setup(QUnit.assert);

setApplication(Application.create(config.APP));

start();

Contributing

See the Contributing guide for details.

Prior Art

  • qunit-dom much of the config for this repo was taken from qunit-dom.

License

This project is licensed under the MIT License.

qunit-assertions-extra's People

Contributors

ember-tomster avatar github-actions[bot] avatar krinkle avatar nullvoxpopuli avatar rohitpaulk avatar yads avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

qunit-assertions-extra's Issues

New assertion - Fuzzy object match

Hi @NullVoxPopuli!

Thanks for putting these together!

Have you considered fuzzy object match similar to what Sinon.js provides?

E.g. sometimes you need to match two objects and you care about one or two or three props but other props are out of concern for the test.

Currently, you can't use assert.deepEqual() as it will compare all props and it's achievable via something like:

const { foo, bar } = myObject.someMethod();

assert.equal(foo, 'foo value');
assert.equal(bar, 'bar value');

would be nice to do something like:

const result = myObject.someMethod();

assert.fuzzyEqual(result, {
  foo: 'foo value',
  bar: 'bar value'
});

where result might contain few more props that we don't care in this test.

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.