Skip to content

Commit

Permalink
Nuke should #3035 (#3042)
Browse files Browse the repository at this point in the history
Removing should library and using expect instead (issue #3035).
Removed should package from package.json.
Removed should from mocha.opts.
Fixed tests.
Added myself to contributors.
Fixed diff fixture to use eql so that the error message produced by expect matches the one that should used to produce.
  • Loading branch information
ngeor authored and ScottFreeCode committed Oct 6, 2017
1 parent eb8bf8d commit dcce850
Show file tree
Hide file tree
Showing 26 changed files with 260 additions and 267 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -198,6 +198,7 @@
"Nathan Houle <nathan+github@nathanhoule.com> (https://github.com/ndhoule)",
"Nathan Rajlich <nathan@tootallnate.net> (https://github.com/TooTallNate)",
"Nick Fitzgerald (https://github.com/fitzgen)",
"Nikolaos Georgiou (https://github.com/ngeor)",
"noirlab (https://github.com/noirlab)",
"Noshir Patel <nosh@blackpiano.com> (https://github.com/noshir-patel)",
"OlegTsyba <oleg.tsyba.ua@gmail.com> (https://github.com/OlegTsyba)",
Expand Down Expand Up @@ -341,7 +342,6 @@
"karma-sauce-launcher": "^1.2.0",
"nyc": "^11.2.1",
"rimraf": "^2.5.2",
"should": "^13.1.0",
"through2": "^2.0.1",
"watchify": "^3.7.0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/compiler-fixtures/foo.fixture.js
Expand Up @@ -6,6 +6,6 @@ require.extensions['.foo'] = function (module, filename) {
var content;
content = fs.readFileSync(filename, 'utf8');
var test = 'describe("custom compiler",function(){ it("should work",function() { ' +
content + '.should.eql(1); }); });';
'expect(' + content + ').to.eql(1); }); });';
return module._compile(test, filename);
};
22 changes: 11 additions & 11 deletions test/integration/fixtures/diffs/diffs.fixture.js
Expand Up @@ -10,19 +10,19 @@ describe('diffs', function () {
it('should display a diff for small strings', function () {
actual = 'foo rar baz';
expected = 'foo bar baz';
actual.should.equal(expected);
expect(actual).to.eql(expected);
});

it('should display a diff of canonicalized objects', function () {
actual = { name: 'travis j', age: 23 };
expected = { age: 23, name: 'travis' };
actual.should.equal(expected);
expect(actual).to.eql(expected);
});

it('should display a diff for medium strings', function () {
actual = 'foo bar baz\nfoo rar baz\nfoo bar raz';
expected = 'foo bar baz\nfoo bar baz\nfoo bar baz';
actual.should.equal(expected);
expect(actual).to.eql(expected);
});

it('should display a diff for entire object dumps', function () {
Expand All @@ -42,13 +42,13 @@ describe('diffs', function () {
country: 'us'
}
};
actual.should.equal(expected);
expect(actual).to.eql(expected);
});

it('should display a diff for multi-line strings', function () {
actual = 'one two three\nfour zzzz six\nseven eight nine';
expected = 'one two three\nfour five six\nseven eight nine';
actual.should.equal(expected);
expect(actual).to.eql(expected);
});

it('should display a diff for entire object dumps', function () {
Expand All @@ -68,17 +68,17 @@ describe('diffs', function () {
country: 'us'
}
};
actual.should.equal(expected);
expect(actual).to.eql(expected);
});

it('should display a full-comparison with escaped special characters', function () {
actual = 'one\ttab\ntwo\t\t\ttabs';
expected = 'one\ttab\ntwo\t\ttabs';
actual.should.equal(expected);
expect(actual).to.eql(expected);
});

it('should display a word diff for large strings', function () {
cssin.should.equal(cssout);
expect(cssin).to.eql(cssout);
});

it('should work with objects', function () {
Expand All @@ -96,18 +96,18 @@ describe('diffs', function () {
age: 2
};

actual.should.eql(expected);
expect(actual).to.eql(expected);
});

it('should show value diffs and not be affected by commas', function () {
actual = { a: 123 };
expected = { a: 123, b: 456 };
actual.should.equal(expected);
expect(actual).to.eql(expected);
});

it('should display diff by data and not like an objects', function () {
actual = new Buffer([0x01]);
expected = new Buffer([0x02]);
actual.should.equal(expected);
expect(actual).to.eql(expected);
});
});
2 changes: 1 addition & 1 deletion test/integration/regression.spec.js
Expand Up @@ -72,7 +72,7 @@ describe('regressions', function () {
it('should be pending', function () {});
});
after('meta test', function () {
afterWasRun.should.be.ok();
expect(afterWasRun).to.be.ok();
});
});

Expand Down
1 change: 0 additions & 1 deletion test/mocha.opts
@@ -1,4 +1,3 @@
--require should
--require ./test/setup
--ui bdd
--globals okGlobalA,okGlobalB
Expand Down
30 changes: 12 additions & 18 deletions test/node-unit/stack-trace-filter.spec.js
Expand Up @@ -28,9 +28,8 @@ describe('stackTraceFilter()', function () {
'Immediate._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:276:5)',
'at processImmediate [as _immediateCallback] (timers.js:321:17)'
];
filter(stack.join('\n'))
.should
.equal(stack.slice(0, 3)
expect(filter(stack.join('\n')))
.to.equal(stack.slice(0, 3)
.join('\n'));

stack = [
Expand All @@ -47,9 +46,8 @@ describe('stackTraceFilter()', function () {
'at processImmediate [as _immediateCallback] (timers.js:321:17)'
];

filter(stack.join('\n'))
.should
.equal(stack.slice(0, 7)
expect(filter(stack.join('\n')))
.to.equal(stack.slice(0, 7)
.join('\n'));
});

Expand All @@ -69,9 +67,8 @@ describe('stackTraceFilter()', function () {
'at file:///.../components/mochajs/mocha/2.1.0/mocha.js:4970:12',
'at next (file:///.../components/mochajs/mocha/2.1.0/mocha.js:4817:14)'
];
filter(stack.join('\n'))
.should
.equal(stack.slice(0, 7)
expect(filter(stack.join('\n')))
.to.equal(stack.slice(0, 7)
.join('\n'));
});

Expand All @@ -88,9 +85,8 @@ describe('stackTraceFilter()', function () {
'at bar (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:11:26)'
];

filter(stack.join('\n'))
.should
.equal(expected.join('\n'));
expect(filter(stack.join('\n')))
.to.equal(expected.join('\n'));
});
});

Expand All @@ -114,9 +110,8 @@ describe('stackTraceFilter()', function () {
'at next (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:284:14)',
'at Immediate._onImmediate (C:\\Users\\ishida\\src\\test\\node_modules\\mocha\\lib\\runner.js:320:5)'
];
filter(stack.join('\n'))
.should
.equal(stack.slice(0, 2)
expect(filter(stack.join('\n')))
.to.equal(stack.slice(0, 2)
.join('\n'));
});
});
Expand All @@ -142,9 +137,8 @@ describe('stackTraceFilter()', function () {
'at localhost:3000/foo/bar/node_modules/mocha.js:4970:12',
'at next (node_modules/mocha.js:4817:14)'
];
filter(stack.join('\n'))
.should
.equal(stack.slice(0, 7)
expect(filter(stack.join('\n')))
.to.equal(stack.slice(0, 7)
.join('\n'));
});

Expand Down
52 changes: 26 additions & 26 deletions test/only/bdd.spec.js
Expand Up @@ -2,77 +2,77 @@

describe('should only run .only test in this bdd suite', function () {
it('should not run this test', function () {
(0).should.equal(1, 'this test should have been skipped');
expect(0).to.equal(1, 'this test should have been skipped');
});
it.only('should run this test', function () {
(0).should.equal(0, 'this .only test should run');
expect(0).to.equal(0, 'this .only test should run');
});
it('should run this test, not (includes the title of the .only test)', function () {
(0).should.equal(1, 'this test should have been skipped');
expect(0).to.equal(1, 'this test should have been skipped');
});
});

describe('should not run this suite', function () {
it('should not run this test', function () {
(true).should.equal(false);
expect(true).to.equal(false);
});

it('should not run this test', function () {
(true).should.equal(false);
expect(true).to.equal(false);
});

it('should not run this test', function () {
(true).should.equal(false);
expect(true).to.equal(false);
});
});

describe.only('should run all tests in this bdd suite', function () {
it('should run this test #1', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});

it('should run this test #2', function () {
(1).should.equal(1);
expect(1).to.equal(1);
});

it('should run this test #3', function () {
('foo').should.equal('foo');
expect('foo').to.equal('foo');
});
});

describe('should run only suites that marked as `only`', function () {
describe.only('should run all this tdd suite', function () {
it('should run this test #1', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});

it('should run this test #2', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});
});

describe('should not run this suite', function () {
it('should run this test', function () {
(true).should.equal(false);
expect(true).to.equal(false);
});
});
});

// Nested situation
describe('should not run parent tests', function () {
it('should not run this test', function () {
(true).should.equal(false);
expect(true).to.equal(false);
});
describe('and not the child tests too', function () {
it('should not run this test', function () {
(true).should.equal(false);
expect(true).to.equal(false);
});
describe.only('but run all the tests in this suite', function () {
it('should run this test #1', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});
it('should run this test #2', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});
});
});
Expand All @@ -81,47 +81,47 @@ describe('should not run parent tests', function () {
// mark test as `only` override the suite behavior
describe.only('should run only tests that marked as `only`', function () {
it('should not run this test #1', function () {
(false).should.equal(true);
expect(false).to.equal(true);
});

it.only('should run this test #2', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});

it('should not run this test #3', function () {
(false).should.equal(true);
expect(false).to.equal(true);
});

it.only('should run this test #4', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});
});

describe.only('Should run only test cases that mark as only', function () {
it.only('should runt his test', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});

it('should not run this test', function () {
(false).should.equal(true);
expect(false).to.equal(true);
});

describe('should not run this suite', function () {
it('should not run this test', function () {
(false).should.equal(true);
expect(false).to.equal(true);
});
});
});

// Root Suite
it.only('#Root-Suite, should run this test-case #1', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});

it.only('#Root-Suite, should run this test-case #2', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});

it('#Root-Suite, should not run this test', function () {
(false).should.equal(true);
expect(false).to.equal(true);
});
6 changes: 3 additions & 3 deletions test/only/global/bdd.spec.js
Expand Up @@ -2,13 +2,13 @@

// Root-only test cases
it.only('#Root-Suite, should run this bdd test-case #1', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});

it('#Root-Suite, should not run this bdd test-case #2', function () {
(false).should.equal(true);
expect(false).to.equal(true);
});

it('#Root-Suite, should not run this bdd test-case #3', function () {
(false).should.equal(true);
expect(false).to.equal(true);
});
6 changes: 3 additions & 3 deletions test/only/global/qunit.spec.js
Expand Up @@ -2,13 +2,13 @@

// Root-only test cases
test.only('#Root-Suite, should run this qunit test-case #1', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});

test('#Root-Suite, should not run this qunit test-case #2', function () {
(false).should.equal(true);
expect(false).to.equal(true);
});

test('#Root-Suite, should not run this qunit test-case #3', function () {
(false).should.equal(true);
expect(false).to.equal(true);
});
6 changes: 3 additions & 3 deletions test/only/global/tdd.spec.js
Expand Up @@ -2,13 +2,13 @@

// Root-only test cases
test.only('#Root-Suite, should run this tdd test-case #1', function () {
(true).should.equal(true);
expect(true).to.equal(true);
});

test('#Root-Suite, should not run this tdd test-case #2', function () {
(false).should.equal(true);
expect(false).to.equal(true);
});

test('#Root-Suite, should not run this tdd test-case #3', function () {
(false).should.equal(true);
expect(false).to.equal(true);
});

0 comments on commit dcce850

Please sign in to comment.