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

Change assert module's deprecated methods in testing files #4435

Merged
merged 5 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/example/debug-hanging-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('how to debug Mocha when it hangs', function () {

it('should complete, but Mocha should not exit', function(done) {
const sock = net.createConnection(10101, () => {
assert.deepEqual(sock.address().family, 'IPv4');
assert.deepStrictEqual(sock.address().family, 'IPv4');
done();
});
});
Expand Down
6 changes: 6 additions & 0 deletions test/integration/diffs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ describe('diffs', function() {
var diffs, expected;

before(function(done) {
// @TODO: It should be removed when Node.js 10 LTS is not supported.
const nodeVersion = parseInt(process.version.match(/^v(\d+)\./)[1], 10);
if (nodeVersion === 10) {
this.skip();
}

run('diffs/diffs.fixture.js', [], function(err, res) {
if (err) {
done(err);
Expand Down
14 changes: 7 additions & 7 deletions test/integration/fixtures/current-test-title.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ function getTitle(ctx) {
};

before(function () {
assert.equal(getTitle(this), undefined);
assert.strictEqual(getTitle(this), undefined);
});

describe('suite A', () => {

before(function () {
assert.equal(getTitle(this), undefined);
assert.strictEqual(getTitle(this), undefined);
});

describe('suite B', () => {
Expand All @@ -23,25 +23,25 @@ describe('suite A', () => {
var lap = 0;

before(function () {
assert.equal(getTitle(this), 'test1 C');
assert.strictEqual(getTitle(this), 'test1 C');
});
beforeEach(function () {
assert.equal(getTitle(this), ++lap === 1 ? 'test1 C' : 'test2 C');
assert.strictEqual(getTitle(this), ++lap === 1 ? 'test1 C' : 'test2 C');
});

it('test1 C', function () {});
it('test2 C', function () {});

afterEach(function () {
assert.equal(getTitle(this), lap === 1 ? 'test1 C' : 'test2 C');
assert.strictEqual(getTitle(this), lap === 1 ? 'test1 C' : 'test2 C');
});
after(function () {
assert.equal(getTitle(this), 'test2 C');
assert.strictEqual(getTitle(this), 'test2 C');
});
});
});
});

after(function () {
assert.equal(getTitle(this), undefined);
assert.strictEqual(getTitle(this), undefined);
});
22 changes: 11 additions & 11 deletions test/integration/fixtures/diffs/diffs.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ describe('diffs', function () {
it('should display a diff for small strings', function () {
actual = 'foo rar baz';
expected = 'foo bar baz';
assert.equal(actual, expected);
assert.strictEqual(actual, expected);
});

it('should display a diff of canonicalized objects', function () {
actual = { name: 'travis j', age: 23 };
expected = { age: 23, name: 'travis' };
assert.deepEqual(actual, expected);
assert.deepStrictEqual(actual, 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';
assert.equal(actual, expected);
assert.strictEqual(actual, expected);
});

it('should display a diff for entire object dumps', function () {
Expand All @@ -44,13 +44,13 @@ describe('diffs', function () {
country: 'us'
}
};
assert.deepEqual(actual, expected);
assert.deepStrictEqual(actual, 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';
assert.equal(actual, expected);
assert.strictEqual(actual, expected);
});

it('should display a diff for entire object dumps', function () {
Expand All @@ -70,17 +70,17 @@ describe('diffs', function () {
country: 'us'
}
};
assert.deepEqual(actual, expected);
assert.deepStrictEqual(actual, 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';
assert.equal(actual, expected);
assert.strictEqual(actual, expected);
});

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

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

assert.deepEqual(actual, expected);
assert.deepStrictEqual(actual, expected);
});

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

it('should display diff by data and not like an objects', function () {
actual = Buffer.from([0x01]);
expected = Buffer.from([0x02]);
assert.deepEqual(actual, expected);
assert.deepStrictEqual(actual, expected);
});
});
2 changes: 1 addition & 1 deletion test/integration/fixtures/no-diff.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ var assert = require('assert');

describe('Example test', function () {
it('should fail', function () {
assert.deepEqual([1, 2, 3], ['foo', 'bar', 'baz']);
assert.deepStrictEqual([1, 2, 3], ['foo', 'bar', 'baz']);
});
});
4 changes: 2 additions & 2 deletions test/integration/fixtures/retries/early-pass.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ describe('retries', function () {
});

it('check for updated `suite.tests`', function() {
assert.equal(self.tests[0]._currentRetry, 1);
assert.strictEqual(self.tests[0]._currentRetry, 1);
assert.ok(self.tests[0]._retriedTest);
assert.equal(self.tests[0].state, 'passed');
assert.strictEqual(self.tests[0].state, 'passed');
})
});
4 changes: 2 additions & 2 deletions test/integration/fixtures/uncaught/listeners.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ for (let i = 0; i < 5; i++) {
r.run();
}

assert.equal(process.listenerCount('uncaughtException'), 1);
assert.equal(process.listeners('uncaughtException')[0].name, 'uncaught');
assert.strictEqual(process.listenerCount('uncaughtException'), 1);
assert.strictEqual(process.listeners('uncaughtException')[0].name, 'uncaught');
6 changes: 6 additions & 0 deletions test/integration/no-diff.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ var run = helpers.runMocha;
describe('no-diff', function() {
describe('when enabled', function() {
it('should not display a diff', function(done) {
// @TODO: It should be removed when Node.js 10 LTS is not supported.
const nodeVersion = parseInt(process.version.match(/^v(\d+)\./)[1], 10);
if (nodeVersion === 10) {
this.skip();
}

run('no-diff.fixture.js', ['--no-diff'], function(err, res) {
if (err) {
done(err);
Expand Down