Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added testling-ci integration. Fixes #124 #149

Closed
wants to merge 9 commits into from
Closed
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[![Build Status](https://travis-ci.org/chaijs/chai.png?branch=master)](https://travis-ci.org/chaijs/chai)

[![browser support](https://ci.testling.com/chaijs/chai.png)](https://ci.testling.com/chaijs/chai)

[![Chai Documentation](http://chaijs.com/public/img/chai-logo.png)](http://chaijs.com)

Chai is a BDD / TDD assertion library for [node](http://nodejs.org) and the browser that
Expand All @@ -14,7 +16,7 @@ For more information or to download plugins, view the [documentation](http://cha
active : 117 days
commits : 616
files : 56
authors :
authors :
459 Jake Luer 74.5%
66 Veselin Todorov 10.7%
42 Domenic Denicola 6.8%
Expand Down
10 changes: 9 additions & 1 deletion chai.js
Original file line number Diff line number Diff line change
Expand Up @@ -2678,6 +2678,10 @@
// and there seems no easy cross-platform way to detect them (@see chaijs/chai/issues/69).
var excludeNames = /^(?:length|name|arguments|caller)$/;

// Cache `Function` properties
var call = Function.prototype.call,
apply = Function.prototype.apply;

/**
* ### addChainableMethod (ctx, name, method, chainingBehavior)
*
Expand Down Expand Up @@ -2721,7 +2725,11 @@

// Use `__proto__` if available
if (hasProtoSupport) {
assert.__proto__ = this;
// Inherit all properties from the object by replacing the `Function` prototype
var prototype = assert.__proto__ = Object.create(this);
// Restore the `call` and `apply` methods from `Function`
prototype.call = call;
prototype.apply = apply;
}
// Otherwise, redefine all properties (slow!)
else {
Expand Down
21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,26 @@
, "mocha-cloud": "*"
, "mocha-phantomjs": "*"
, "connect": "2.7.x"
},
"testling": {
"files": [],
"scripts": [
"chai.js",
"test/browser/bootstrap.js",
"test/*.js"
],
"harness": "mocha-tdd",
"browsers": [
"ie/6..latest",
"chrome/20..latest",
"chrome/canary",
"firefox/10..latest",
"firefox/nightly",
"safari/latest",
"opera/11.0..latest",
"opera/next",
"iphone/6",
"ipad/6"
]
}
}
12 changes: 12 additions & 0 deletions test/browser/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
err = function (fn, msg) {
try {
fn();
throw new chai.AssertionError({ message: 'Expected an error' });
} catch (err) {
if ('string' === typeof msg) {
chai.expect(err.message).to.equal(msg);
} else {
chai.expect(err.message).to.match(msg);
}
}
};
15 changes: 1 addition & 14 deletions test/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,7 @@
<script src="../../node_modules/mocha/mocha.js"></script>
<script>mocha.setup('tdd')</script>
<script src="../../chai.js"></script>
<script>
err = function (fn, msg) {
try {
fn();
throw new chai.AssertionError({ message: 'Expected an error' });
} catch (err) {
if ('string' === typeof msg) {
chai.expect(err.message).to.equal(msg);
} else {
chai.expect(err.message).to.match(msg);
}
}
};
</script>
<script src="bootstrap.js"></script>
<script src="../configuration.js"></script>
<script src="../expect.js"></script>
<script src="../should.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion test/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ suite('expect', function () {

err(function(){
expect(2).to.satisfy(matcher, 'blah');
}, "blah: expected 2 to satisfy [Function: matcher]");
}, /blah: expected 2 to satisfy \[Function: matcher\s*\]/);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a patch so that IE10 would pass its test. It turns out named functions in IE10 look like "[Function: matcher ]" vs normal browsers with "[Function: matcher]".

This can be seen on https://ci.testling.com/twolfson/chai under d753a4a -> IE10 -> not ok 80 expect satisfy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include in a different PR? Would like to get it included asap (ci stuff might take longer) and want to make sure you get credit for the contribution.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing. I was hesitant on tossing this in here but it seemed like such a small change. One updated PR coming up!

});

test('closeTo', function(){
Expand Down