Git Product home page Git Product logo

chai-custom-assertions's People

Contributors

ellenmobify avatar vmarta avatar

Watchers

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

Forkers

iqbmo04

chai-custom-assertions's Issues

Element assertion does not work for jQuery derived elements

jQuery elements that have been derived from other jQuery elements no longer have their own selector property, which causes the element test to fail.

var $original = $('div');
var $derived = $original.clone();

expect($original).to.be.an.element(); // passes
expect($derived).to.be.an.element(); // fails

Other functions such as .children(), .first(), .filter() have the same issue.

Element and Present assertions do not work as properties

The following assertions do not work correctly:

expect($paymentOptions).to.be.an.element;
expect($paymentOptions).to.be.present;

Using the above syntax instead of the .element(value) syntax does not actually invoke the test. Because Chai assumes that tests pass until they fail, this may lead to tests that pass when they should not.

How to Test

  • Use an existing adaptive project with fixtures already set up
  • Create a new test that should fail
test('custom assertions', view, fixture, {
    'present fails for a nonexistent element': function($, context) {
        var $fakeElement = $('#fake-element');
        expect($fakeElement).to.be.present;
    },
    'element fails for an object that is not a jQuery or Zepto element': function($, context) {
        var notElement = {};
        expect(notElement).to.be.an.element;
   }
});
  • This test will pass, despite the fact that it should fail
  • Using the other syntax invokes the tests correctly
test('custom assertions', view, fixture, {
    'present fails for a nonexistent element': function($, context) {
        var $fakeElement = $('#fake-element');
        expect($fakeElement).to.be.present(1);
    },
    'element fails for an object that is not a jQuery or Zepto element': function($, context) {
        var notElement = {};
        expect(notElement).to.be.an.element();
   }
});

Update Chai to 2.x

We are currently using Chai 1.9.0.

2.x should be compatible with our existing tests and custom assertions. New features include:

Tasks

  • Update Chai version in adaptive
  • Ensure new version works with custom commands and existing tests

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.