Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
fix CI; closes mochajs#2867 (mochajs#2868)
Browse files Browse the repository at this point in the history
* load karma plugins explicitly; closes mochajs#2867

* don't use "should" for unit tests; closes mochajs#2882

* fix some broken browser tests

* fix some problem tests in obsolete browsers

* phantomjs fixes
  • Loading branch information
boneskull authored Jun 16, 2017
1 parent 425549e commit 88c7728
Show file tree
Hide file tree
Showing 14 changed files with 369 additions and 271 deletions.
9 changes: 9 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ module.exports = function (config) {
'expect',
'mocha'
],
plugins: [
'karma-browserify',
'karma-chrome-launcher',
'karma-phantomjs-launcher',
'karma-expect',
'karma-mocha',
'karma-spec-reporter',
require('@coderbyheart/karma-sauce-launcher')
],
files: [
// we use the BDD interface for all of the tests that
// aren't interface-specific.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@
"supports-color": "3.1.2"
},
"devDependencies": {
"@coderbyheart/karma-sauce-launcher": "coderbyheart/karma-sauce-launcher#5259942cd6d40090eaa13ceeef5b0b8738c7710f",
"assert": "^1.4.1",
"browserify": "^13.0.0",
"coffee-script": "^1.10.0",
Expand All @@ -337,7 +338,6 @@
"karma-expect": "^1.1.2",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "0.2.3",
"karma-sauce-launcher": "coderbyheart/karma-sauce-launcher",
"karma-spec-reporter": "0.0.26",
"nyc": "^10.0.0",
"os-name": "^2.0.1",
Expand Down
3 changes: 1 addition & 2 deletions test/jsapi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ var mocha = new Mocha({
growl: true
});

// mocha.reporter('spec');
require('should');
global.expect = require('expect.js');

mocha.addFile('test/unit/suite.spec.js');
mocha.addFile('test/unit/runner.spec.js');
Expand Down
12 changes: 6 additions & 6 deletions test/unit/grep.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ describe('Mocha', function () {
describe('"grep" option', function () {
it('should add a RegExp to the mocha.options object', function () {
var mocha = new Mocha({ grep: /foo.*/ });
mocha.options.grep.toString().should.equal('/foo.*/');
expect(mocha.options.grep.toString()).to.equal('/foo.*/');
});

it('should convert string to a RegExp', function () {
var mocha = new Mocha({ grep: 'foo.*' });
mocha.options.grep.toString().should.equal('/foo.*/');
expect(mocha.options.grep.toString()).to.equal('/foo.*/');
});
});

describe('"fgrep" option', function () {
it('should escape and convert string to a RegExp', function () {
var mocha = new Mocha({ fgrep: 'foo.*' });
mocha.options.grep.toString().should.equal('/foo\\.\\*/');
expect(mocha.options.grep.toString()).to.equal('/foo\\.\\*/');
});
});

Expand All @@ -27,7 +27,7 @@ describe('Mocha', function () {
function testGrep (mocha) {
return function testGrep (grep, expected) {
mocha.grep(grep);
mocha.options.grep.toString().should.equal(expected);
expect(mocha.options.grep.toString()).to.equal(expected);
};
}

Expand All @@ -54,14 +54,14 @@ describe('Mocha', function () {

it('should return it\'s parent Mocha object for chainability', function () {
var mocha = new Mocha();
mocha.grep().should.equal(mocha);
expect(mocha.grep()).to.equal(mocha);
});
});

describe('"invert" option', function () {
it('should add a Boolean to the mocha.options object', function () {
var mocha = new Mocha({ invert: true });
mocha.options.invert.should.be.ok;
expect(mocha.options.invert).to.be.ok;
});
});
});
8 changes: 4 additions & 4 deletions test/unit/hook-async.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('async', function () {

after(function () {
calls.push('root after all');
calls.should.eql([
expect(calls).to.eql([
'root before all',
'before all',
'parent before',
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('async', function () {
});

it('one', function (done) {
calls.should.eql([
expect(calls).to.eql([
'root before all',
'before all',
'parent before',
Expand All @@ -79,7 +79,7 @@ describe('async', function () {
});

it('two', function () {
calls.should.eql([
expect(calls).to.eql([
'root before all',
'before all',
'parent before',
Expand All @@ -97,7 +97,7 @@ describe('async', function () {
});

it('three', function () {
calls.should.eql([
expect(calls).to.eql([
'root before all',
'before all',
'parent before',
Expand Down
8 changes: 4 additions & 4 deletions test/unit/hook-sync-nested.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ describe('serial', function () {
});

it('foo', function () {
calls.should.eql([
expect(calls).to.eql([
'parent before',
'parent before test foo'
]);
calls.push('foo');
});

it('bar', function () {
calls.should.eql([
expect(calls).to.eql([
'parent before',
'parent before test foo',
'foo',
Expand All @@ -47,7 +47,7 @@ describe('serial', function () {
});

it('one', function () {
calls.should.eql([
expect(calls).to.eql([
'parent before',
'parent before test foo',
'foo',
Expand All @@ -66,7 +66,7 @@ describe('serial', function () {
});

it('two', function () {
calls.should.eql([
expect(calls).to.eql([
'parent before',
'parent before test foo',
'foo',
Expand Down
8 changes: 4 additions & 4 deletions test/unit/hook-sync.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('serial', function () {
});

it('one', function () {
calls.should.eql([
expect(calls).to.eql([
'parent before',
'before',
'before test one'
Expand All @@ -29,7 +29,7 @@ describe('serial', function () {
});

it('two', function () {
calls.should.eql([
expect(calls).to.eql([
'parent before',
'before',
'before test one',
Expand All @@ -45,7 +45,7 @@ describe('serial', function () {
});

it('three', function () {
calls.should.eql([
expect(calls).to.eql([
'parent before',
'before',
'before test one',
Expand Down Expand Up @@ -75,7 +75,7 @@ describe('serial', function () {
});

after(function () {
calls.should.eql([
expect(calls).to.eql([
'parent before',
'before',
'before test one',
Expand Down
2 changes: 1 addition & 1 deletion test/unit/mocha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Mocha', function () {
});
mocha.suite.addTest(failingTest);
mocha.run(function (failures) {
failures.should.equal(1);
expect(failures).to.equal(1);
done();
});
});
Expand Down
50 changes: 25 additions & 25 deletions test/unit/ms.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,72 +11,72 @@ describe('.ms()', function () {
};
describe('get a value that less than 1 second', function () {
it('should return milliseconds representation', function () {
ms(200).should.equal('200ms');
ms(30).should.equal('30ms');
ms(2000).should.not.equal('2000ms');
expect(ms(200)).to.equal('200ms');
expect(ms(30)).to.equal('30ms');
expect(ms(2000)).to.not.equal('2000ms');
});
});

describe('seconds representation', function () {
it('should return short format', function () {
ms(2000).should.equal('2s');
expect(ms(2000)).to.equal('2s');
});

it('should return long format', function () {
ms(2000, { long: true }).should.equal('2 seconds');
ms(1000, { long: true }).should.equal('1 second');
ms(1010, { long: true }).should.equal('1 second');
expect(ms(2000, { long: true })).to.equal('2 seconds');
expect(ms(1000, { long: true })).to.equal('1 second');
expect(ms(1010, { long: true })).to.equal('1 second');
});
});

describe('minutess representation', function () {
it('should return short format', function () {
ms(time.minutes(1)).should.equal('1m');
expect(ms(time.minutes(1))).to.equal('1m');
});

it('should return long format', function () {
ms(time.minutes(1), { long: true }).should.equal('1 minute');
ms(time.minutes(3), { long: true }).should.equal('3 minutes');
expect(ms(time.minutes(1), { long: true })).to.equal('1 minute');
expect(ms(time.minutes(3), { long: true })).to.equal('3 minutes');
});
});

describe('hours representation', function () {
it('should return short format', function () {
ms(time.hours(1)).should.equal('1h');
expect(ms(time.hours(1))).to.equal('1h');
});

it('should return long format', function () {
ms(time.hours(1), { long: true }).should.equal('1 hour');
ms(time.hours(3), { long: true }).should.equal('3 hours');
expect(ms(time.hours(1), { long: true })).to.equal('1 hour');
expect(ms(time.hours(3), { long: true })).to.equal('3 hours');
});
});

describe('days representation', function () {
it('should return short format', function () {
ms(time.days(1)).should.equal('1d');
expect(ms(time.days(1))).to.equal('1d');
});

it('should return long format', function () {
ms(time.days(1), { long: true }).should.equal('1 day');
ms(time.days(3), { long: true }).should.equal('3 days');
expect(ms(time.days(1), { long: true })).to.equal('1 day');
expect(ms(time.days(3), { long: true })).to.equal('3 days');
});
});

describe('Getting string value', function () {
it('should return the milliseconds representation(Number)', function () {
ms('1 second').should.equal(1000);
expect(ms('1 second')).to.equal(1000);

ms('1 minute').should.equal(time.minutes(1));
ms('6 minutes').should.equal(time.minutes(6));
expect(ms('1 minute')).to.equal(time.minutes(1));
expect(ms('6 minutes')).to.equal(time.minutes(6));

ms('1 hour').should.equal(time.hours(1));
ms('5 hours').should.equal(time.hours(5));
expect(ms('1 hour')).to.equal(time.hours(1));
expect(ms('5 hours')).to.equal(time.hours(5));

ms('1 day').should.equal(time.days(1));
ms('3 days').should.equal(time.days(3));
expect(ms('1 day')).to.equal(time.days(1));
expect(ms('3 days')).to.equal(time.days(3));

ms('1 year').should.equal(time.years(1));
ms('2 years').should.equal(time.years(2));
expect(ms('1 year')).to.equal(time.years(1));
expect(ms('2 years')).to.equal(time.years(2));
});
});
});
Loading

0 comments on commit 88c7728

Please sign in to comment.