spmason / expectations Goto Github PK
View Code? Open in Web Editor NEWJasmine-style expect syntax for nodejs + browser
License: BSD Zero Clause License
Jasmine-style expect syntax for nodejs + browser
License: BSD Zero Clause License
expectations.js == index.js
Maximum call stack size exceeded
at file://localhost/Users/wyuenho/Documents/workspace/backgrid/assets/js/expectations.js:74:71
at Array.map (native)
at formatValue (file://localhost/Users/wyuenho/Documents/workspace/backgrid/assets/js/expectations.js:73:39)
at file://localhost/Users/wyuenho/Documents/workspace/backgrid/assets/js/expectations.js:74:34
at Array.map (native)
at formatValue (file://localhost/Users/wyuenho/Documents/workspace/backgrid/assets/js/expectations.js:73:39)
at formatValue (file://localhost/Users/wyuenho/Documents/workspace/backgrid/assets/js/expectations.js:57:21)
at file://localhost/Users/wyuenho/Documents/workspace/backgrid/assets/js/expectations.js:74:34
at Array.map (native)
at formatValue (file://localhost/Users/wyuenho/Documents/workspace/backgrid/assets/js/expectations.js:73:39)
The trick to switch the assertion.pass / assertion.fail methods for "not" chaining causes every assertion that does not assign arguments to the pass method to not show an error message. Affected are:
Sincerely
Alex
var a = new Uint8Array([2, 3]);
var b = new Uint8Array([2, 3]);
var c = new Uint8Array([1, 2, 3]);
expect(b).toEqual(a); // Works
expect(c.subarray(1)).toEqual(a); // Fails on Android browser <= 4.3
To fix this, typed arrays should be compared the same way regular arrays are, by elements and length only. It seems that on these versions of the Android browser, an additional property, such as 'offset' (just a suspicion) may also be compared (perhaps somewhere deeper in the object graph), causing the failure.
I don't really have the ability to debug this at the moment (there's no error console on android, and setting up remote debugging would take time). I've reproduced it using the Android Emulator on versions 4.0.3, 4.2.2 and 4.3.1 (earlier Android browser versions don't support typed arrays, I believe, so are not relevant). It did not happen on 4.4.2, 5.0.2 or 6.0 or any other browser that I've tried (I have not really tested it on mobile or desktop Safari though).
A rough fix (for Uint8Array
only - just for demonstration). I changed line 143 from:
if (className == '[object Array]')
to
if (className == '[object Array]' || className == '[object Uint8Array]')
You are awesome. I hate expect.js and Chai's expect(yourMum).to.be.a.woman() style of matchers. Too much typing and namespace abuse. You've managed to port Jasmine's entire set of default matchers to Mocha. I salute you.
I believe this project deserve a whole lot more stars then it does now. I think it probably has to do with the lack of documentation. I've managed to painlessly integrate this package into my test harness, but other people might not be able to figure this out. What do you think?
For those of us who prefer to avoid globals.
It's excellent that you already have good test coverage, but CI on pull requests would be the icing on the cake.
Jasmine has a very simple spy and mock facility, it would be nice if this library could incorporate that.
Need the ability to add custom matchers like Jasmines this.addMatcher(function () {})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.