From ac58e94f69ac11eaa0ccea3543698d6513fe0c0a Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Sat, 19 May 2018 02:05:16 +0000 Subject: [PATCH 01/34] Upgrade mocha to version 5.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ba7a19751..aa9181bf7 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "jasmine-core": "^3.1.0", "jest": "^22.4.3", "minimist": "^1.2.0", - "mocha": "^3.2.0", + "mocha": "^5.2.0", "mocha-phantomjs-core": "^2.1.2", "mocha-slow-reporter": "^*", "node-version-check": "^2.2.0", From bcb372f372a5d3d1cc67bcd6daacc1ef007f6f4e Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Mon, 25 Jun 2018 07:50:27 +0000 Subject: [PATCH 02/34] Upgrade eslint-config-pretty-standard to version 2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 021a59657..c083351f9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "coveralls": "^3.0.0", "es5-shim": "^4.5.9", "eslint": "^4.17.0", - "eslint-config-pretty-standard": "^1.2.0", + "eslint-config-pretty-standard": "^2.0.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-prettier": "^2.6.0", "find-node-modules": "^1.0.4", From 8f3de44c2abfee2eb882b85ed2fa46dbe435a1e6 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Mon, 27 Aug 2018 19:50:33 +0000 Subject: [PATCH 03/34] Update nyc to version 13.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 62fe667ef..14174d63f 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "mocha-phantomjs-core": "^2.1.2", "mocha-slow-reporter": "^*", "node-version-check": "^2.2.0", - "nyc": "^10.3.2", + "nyc": "^13.0.1", "offline-github-changelog": "^1.2.0", "prettier": "~1.14.0", "rollup": "^0.63.0", From 0bd0137c207b07d96f1305c4fa4ce68313cf408c Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Sat, 1 Sep 2018 05:05:25 +0000 Subject: [PATCH 04/34] Update eslint to version 5.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 62fe667ef..37a366dc9 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "babel-preset-es2015-without-strict": "^0.0.4", "coveralls": "^3.0.0", "es5-shim": "^4.5.9", - "eslint": "^4.17.0", + "eslint": "^5.5.0", "eslint-config-pretty-standard": "^1.2.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-prettier": "^2.6.0", From cfb01bce26b30d80e9e53964a85341862d496a45 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Wed, 5 Sep 2018 07:55:38 +0000 Subject: [PATCH 05/34] Update rollup to version 0.65.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 62fe667ef..fbd4257d7 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "nyc": "^10.3.2", "offline-github-changelog": "^1.2.0", "prettier": "~1.14.0", - "rollup": "^0.63.0", + "rollup": "^0.65.1", "rollup-plugin-commonjs": "^9.1.0", "rollup-plugin-node-globals": "^1.1.0", "rollup-plugin-node-resolve": "^3.0.0", From eabe62d926901887d515a4db2f4c942dcfacfef6 Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Wed, 5 Sep 2018 20:40:37 +0200 Subject: [PATCH 06/34] Revert "Revert "Merge pull request #482 from alexjeffburke/feature/includeNonEnumerableProperties"" This reverts commit aeac1ef6690647fd8d434856260cb5242ced0b8d. --- documentation/api/addType.md | 54 +++++++-------- lib/assertions.js | 87 +++++++++++------------- lib/types.js | 57 ++++------------ lib/utils.js | 42 ++++++++++++ test/api/inspect.spec.js | 10 +-- test/assertions/to-have-property.spec.js | 9 ++- test/assertions/to-satisfy.spec.js | 11 ++- test/types/error-type.spec.js | 22 +++++- 8 files changed, 160 insertions(+), 132 deletions(-) diff --git a/documentation/api/addType.md b/documentation/api/addType.md index 6e02de1d9..9f858232d 100644 --- a/documentation/api/addType.md +++ b/documentation/api/addType.md @@ -299,13 +299,13 @@ block. The outputs below shows the contrast between setting the inlineDiff = true; expect( { - 'John Doe': new Person('John Doe', 42), - 'Jane Doe': new Person('Janie Doe', 24) + JohnDoe: new Person('John Doe', 42), + JaneDoe: new Person('Janie Doe', 24) }, 'to equal', { - 'John Doe': new Person('John Doe', 42), - 'Jane Doe': new Person('Jane Doe', 24) + JohnDoe: new Person('John Doe', 42), + JaneDoe: new Person('Jane Doe', 24) } ); ``` @@ -313,18 +313,18 @@ expect( ```output expected { - 'John Doe': new Person('John Doe', 42), - 'Jane Doe': new Person('Janie Doe', 24) + JohnDoe: new Person('John Doe', 42), + JaneDoe: new Person('Janie Doe', 24) } to equal { - 'John Doe': new Person('John Doe', 42), - 'Jane Doe': new Person('Jane Doe', 24) + JohnDoe: new Person('John Doe', 42), + JaneDoe: new Person('Jane Doe', 24) } { - 'John Doe': new Person('John Doe', 42), - 'Jane Doe': new Person( + JohnDoe: new Person('John Doe', 42), + JaneDoe: new Person( 'Janie Doe', // should be 'Jane Doe' // -Janie Doe // +Jane Doe @@ -337,13 +337,13 @@ to equal inlineDiff = false; expect( { - 'John Doe': new Person('John Doe', 42), - 'Jane Doe': new Person('Janie Doe', 24) + JohnDoe: new Person('John Doe', 42), + JaneDoe: new Person('Janie Doe', 24) }, 'to equal', { - 'John Doe': new Person('John Doe', 42), - 'Jane Doe': new Person('Jane Doe', 24) + JohnDoe: new Person('John Doe', 42), + JaneDoe: new Person('Jane Doe', 24) } ); ``` @@ -351,25 +351,25 @@ expect( ```output expected { - 'John Doe': new Person('John Doe', 42), - 'Jane Doe': new Person('Janie Doe', 24) + JohnDoe: new Person('John Doe', 42), + JaneDoe: new Person('Janie Doe', 24) } to equal { - 'John Doe': new Person('John Doe', 42), - 'Jane Doe': new Person('Jane Doe', 24) + JohnDoe: new Person('John Doe', 42), + JaneDoe: new Person('Jane Doe', 24) } { - 'John Doe': new Person('John Doe', 42), - 'Jane Doe': new Person('Janie Doe', 24) // should equal new Person('Jane Doe', 24) - // - // new Person( - // 'Janie Doe', // should be 'Jane Doe' - // // -Janie Doe - // // +Jane Doe - // 24 - // ) + JohnDoe: new Person('John Doe', 42), + JaneDoe: new Person('Janie Doe', 24) // should equal new Person('Jane Doe', 24) + // + // new Person( + // 'Janie Doe', // should be 'Jane Doe' + // // -Janie Doe + // // +Jane Doe + // 24 + // ) } ``` diff --git a/lib/assertions.js b/lib/assertions.js index 8e356b8b8..58770465a 100644 --- a/lib/assertions.js +++ b/lib/assertions.js @@ -1799,27 +1799,35 @@ module.exports = expect => { if (valueType.is('array-like') && !subjectIsArrayLike) { expect.fail(); } - const promiseByKey = {}; - const keys = valueType.getKeys(value); + const subjectKeys = subjectType.getKeys(subject); + const valueKeys = valueType.getKeys(value); + // calculate the unique keys early given enumerability no + // longer affects what is included in the list of keys + const uniqueKeys = subjectType.uniqueKeys(subjectKeys, valueKeys); - if (!subjectIsArrayLike) { - // Find all non-enumerable subject keys present in value, but not returned by subjectType.getKeys: - keys.forEach(key => { - if ( - Object.prototype.hasOwnProperty.call(subject, key) && - subjectKeys.indexOf(key) === -1 - ) { - subjectKeys.push(key); + const promiseByKey = {}; + let forceExhaustivelyComparison = false; + uniqueKeys.forEach((key, index) => { + const subjectKey = subjectType.valueForKey(subject, key); + const valueKey = valueType.valueForKey(value, key); + const valueKeyType = expect.findTypeOf(valueKey); + const isDefinedSubjectKey = typeof subjectKey !== 'undefined'; + const isDefinedValueKey = typeof valueKey !== 'undefined'; + + if (expect.flags.exhaustively) { + if (valueKeyType.is('expect.it') && !isDefinedSubjectKey) { + // ensure value only expect.it key is marked missing + forceExhaustivelyComparison = true; } - }); - } + } else { + if (isDefinedSubjectKey && !isDefinedValueKey) { + // ignore subject only keys unless we are being exhaustive + return; + } + } - keys.forEach((key, index) => { promiseByKey[key] = expect.promise(() => { - const subjectKey = subjectType.valueForKey(subject, key); - const valueKey = valueType.valueForKey(value, key); - const valueKeyType = expect.findTypeOf(valueKey); if (valueKeyType.is('expect.it')) { expect.context.thisObject = subject; return valueKey(subjectKey, expect.context); @@ -1834,25 +1842,8 @@ module.exports = expect => { return expect.promise .all([ expect.promise(() => { - if (expect.flags.exhaustively) { - const nonOwnKeysWithDefinedValues = keys.filter( - key => - !Object.prototype.hasOwnProperty.call(subject, key) && - typeof subjectType.valueForKey(subject, key) !== 'undefined' - ); - const valueKeysWithDefinedValues = keys.filter( - key => typeof valueType.valueForKey(value, key) !== 'undefined' - ); - const subjectKeysWithDefinedValues = subjectKeys.filter( - key => - typeof subjectType.valueForKey(subject, key) !== 'undefined' - ); - expect( - valueKeysWithDefinedValues.length - - nonOwnKeysWithDefinedValues.length, - 'to equal', - subjectKeysWithDefinedValues.length - ); + if (forceExhaustivelyComparison) { + throw new Error('exhaustive comparison failure'); } }), expect.promise.all(promiseByKey) @@ -1863,16 +1854,13 @@ module.exports = expect => { diff(output, diff, inspect, equal) { output.inline = true; const subjectIsArrayLike = subjectType.is('array-like'); - const valueKeys = valueType.getKeys(value); - const keys = subjectType - .uniqueKeys(subjectKeys, valueKeys) - .filter(key => { - // Skip missing keys expected to be missing so they don't get rendered in the diff - return ( - subjectType.hasKey(subject, key) || - typeof valueType.valueForKey(value, key) !== 'undefined' - ); - }); + // Skip missing keys expected to be missing so they don't get rendered in the diff + const keys = uniqueKeys.filter(key => { + return ( + subjectType.hasKey(subject, key) || + typeof valueType.valueForKey(value, key) !== 'undefined' + ); + }); const prefixOutput = subjectType.prefix( output.clone(), subject @@ -2360,14 +2348,19 @@ module.exports = expect => { } }); }, - err => + err => { + if (err.isOperational && !err.propertyIsEnumerable('isOperational')) { + delete err.isOperational; + } + expect.withError( () => expect.shift(err), e => { e.originalError = err; throw e; } - ) + ); + } ); } ); diff --git a/lib/types.js b/lib/types.js index 132942b09..e7002d6d1 100644 --- a/lib/types.js +++ b/lib/types.js @@ -114,7 +114,7 @@ module.exports = function(expect) { }, getKeys: Object.getOwnPropertySymbols ? obj => { - const keys = Object.keys(obj); + const keys = Object.getOwnPropertyNames(obj); const symbols = Object.getOwnPropertySymbols(obj); if (symbols.length > 0) { return keys.concat(symbols); @@ -122,7 +122,7 @@ module.exports = function(expect) { return keys; } } - : Object.keys, + : Object.getOwnPropertyNames, // If Symbol support is not detected default to undefined which, when // passed to Array.prototype.sort, means "natural" (asciibetical) sort. keyComparator: @@ -154,44 +154,7 @@ module.exports = function(expect) { } : undefined, equal(a, b, equal) { - if (a === b) { - return true; - } - - if (b.constructor !== a.constructor) { - return false; - } - - const actualKeys = this.getKeys(a).filter( - key => typeof this.valueForKey(a, key) !== 'undefined' - ); - const expectedKeys = this.getKeys(b).filter( - key => typeof this.valueForKey(b, key) !== 'undefined' - ); - - // having the same number of owned properties (keys incorporates hasOwnProperty) - if (actualKeys.length !== expectedKeys.length) { - return false; - } - //the same set of keys (although not necessarily the same order), - actualKeys.sort(this.keyComparator); - expectedKeys.sort(this.keyComparator); - // cheap key test - for (let i = 0; i < actualKeys.length; i += 1) { - if (actualKeys[i] !== expectedKeys[i]) { - return false; - } - } - - //equivalent values for every corresponding key, and - // possibly expensive deep test - for (let j = 0; j < actualKeys.length; j += 1) { - const key = actualKeys[j]; - if (!equal(this.valueForKey(a, key), this.valueForKey(b, key))) { - return false; - } - } - return true; + return utils.checkObjectEqualityUsingType(a, b, this, equal); }, hasKey(obj, key) { return key in obj; @@ -799,12 +762,20 @@ module.exports = function(expect) { 'sourceId', 'sourceURL', 'stack', - 'stackArray' + 'stackArray', + '__stackCleaned__', + 'isOperational' // added by the promise implementation ].reduce((result, prop) => { result[prop] = true; return result; }, {}); + if (new Error().hasOwnProperty('arguments')) { + // node.js 0.10 adds two extra non-enumerable properties to Error instances: + errorMethodBlacklist.arguments = true; + errorMethodBlacklist.type = true; + } + expect.addType({ base: 'object', name: 'Error', @@ -826,7 +797,9 @@ module.exports = function(expect) { }, equal(a, b, equal) { return ( - a === b || (equal(a.message, b.message) && this.baseType.equal(a, b)) + a === b || + (equal(a.message, b.message) && + utils.checkObjectEqualityUsingType(a, b, this, equal)) ); }, inspect(value, depth, output, inspect) { diff --git a/lib/utils.js b/lib/utils.js index 6b8217f87..20c23bb0b 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -27,6 +27,48 @@ const utils = (module.exports = { return a === b; }), + checkObjectEqualityUsingType(a, b, type, isEqual) { + if (a === b) { + return true; + } + + if (b.constructor !== a.constructor) { + return false; + } + + const actualKeys = type + .getKeys(a) + .filter(key => typeof type.valueForKey(a, key) !== 'undefined'); + const expectedKeys = type + .getKeys(b) + .filter(key => typeof type.valueForKey(b, key) !== 'undefined'); + + // having the same number of owned properties (keys incorporates hasOwnProperty) + if (actualKeys.length !== expectedKeys.length) { + return false; + } + + //the same set of keys (although not necessarily the same order), + actualKeys.sort(type.keyComparator); + expectedKeys.sort(type.keyComparator); + // cheap key test + for (let i = 0; i < actualKeys.length; i += 1) { + if (actualKeys[i] !== expectedKeys[i]) { + return false; + } + } + + //equivalent values for every corresponding key, and + // possibly expensive deep test + for (let j = 0; j < actualKeys.length; j += 1) { + const key = actualKeys[j]; + if (!isEqual(type.valueForKey(a, key), type.valueForKey(b, key))) { + return false; + } + } + return true; + }, + duplicateArrayLikeUsingType(obj, type) { const keys = type.getKeys(obj); diff --git a/test/api/inspect.spec.js b/test/api/inspect.spec.js index bd6877ac5..92a941b5f 100644 --- a/test/api/inspect.spec.js +++ b/test/api/inspect.spec.js @@ -207,9 +207,9 @@ describe('inspect', function() { deeply: { nested: { object: 'This should not be shown' }, string: 'should be shown', - 'a list': [1, 2, 3] + list: [1, 2, 3] }, - 'a list': [1, 2, 3] + list: [1, 2, 3] } } } @@ -269,8 +269,8 @@ describe('inspect', function() { ' circular: { self: [Circular] },\n' + ' this: {\n' + ' is: {\n' + - " deeply: { nested: ..., string: 'should be shown', 'a list': ... },\n" + - " 'a list': [ 1, 2, 3 ]\n" + + " deeply: { nested: ..., string: 'should be shown', list: ... },\n" + + ' list: [ 1, 2, 3 ]\n' + ' }\n' + ' }\n' + ' }\n' + @@ -321,7 +321,7 @@ describe('inspect', function() { " { id: 4, name: 'Barbara Lynn' },\n" + " { id: 5, name: 'Sharpe Downs' }\n" + ' ],\n' + - " circular: { self: [Circular] }, this: { is: { deeply: { nested: ..., string: 'should be shown', 'a list': ... }, 'a list': [ 1, 2, 3 ] } }\n" + + " circular: { self: [Circular] }, this: { is: { deeply: { nested: ..., string: 'should be shown', list: ... }, list: [ 1, 2, 3 ] } }\n" + ' }\n' + ']' ); diff --git a/test/assertions/to-have-property.spec.js b/test/assertions/to-have-property.spec.js index 6c255fc47..5460683ab 100644 --- a/test/assertions/to-have-property.spec.js +++ b/test/assertions/to-have-property.spec.js @@ -42,21 +42,24 @@ describe('to have property assertion', function() { expect(subject, 'to have enumerable property', 'enumFalse'); }, 'to throw exception', - "expected { a: 'b' } to have enumerable property 'enumFalse'" + "expected { a: 'b', enumFalse: 't', configFalse: 't', writableFalse: 't' }\n" + + "to have enumerable property 'enumFalse'" ); expect( function() { expect(subject, 'to have configurable property', 'configFalse'); }, 'to throw exception', - "expected { a: 'b' } to have configurable property 'configFalse'" + "expected { a: 'b', enumFalse: 't', configFalse: 't', writableFalse: 't' }\n" + + "to have configurable property 'configFalse'" ); expect( function() { expect(subject, 'to have writable property', 'writableFalse'); }, 'to throw exception', - "expected { a: 'b' } to have writable property 'writableFalse'" + "expected { a: 'b', enumFalse: 't', configFalse: 't', writableFalse: 't' }\n" + + "to have writable property 'writableFalse'" ); }); }); diff --git a/test/assertions/to-satisfy.spec.js b/test/assertions/to-satisfy.spec.js index 458b29d18..a0a7e0bde 100644 --- a/test/assertions/to-satisfy.spec.js +++ b/test/assertions/to-satisfy.spec.js @@ -2194,7 +2194,8 @@ describe('to satisfy assertion', function() { }); }, 'to throw', - "expected {} to exhaustively satisfy { nonEnumerable: 'wrong' }\n" + + "expected { nonEnumerable: 'theValue' }\n" + + "to exhaustively satisfy { nonEnumerable: 'wrong' }\n" + '\n' + '{\n' + ' nonEnumerable:\n' + @@ -2208,10 +2209,6 @@ describe('to satisfy assertion', function() { }); describe('when not matching the non-enumerable property', function() { - it('should succeed', function() { - expect(bar, 'to exhaustively satisfy', {}); - }); - it('should fail with a diff', function() { expect( function() { @@ -2220,9 +2217,11 @@ describe('to satisfy assertion', function() { }); }, 'to throw', - "expected {} to exhaustively satisfy { somethingElse: 'wrong' }\n" + + "expected { nonEnumerable: 'theValue' }\n" + + "to exhaustively satisfy { somethingElse: 'wrong' }\n" + '\n' + '{\n' + + " nonEnumerable: 'theValue' // should be removed\n" + " // missing somethingElse: 'wrong'\n" + '}' ); diff --git a/test/types/error-type.spec.js b/test/types/error-type.spec.js index 10650341a..230f3ab7b 100644 --- a/test/types/error-type.spec.js +++ b/test/types/error-type.spec.js @@ -61,8 +61,14 @@ describe('Error type', function() { } function MyError(message) { - Error.call(this); - this.message = message; + var instance = new Error(message); + var proto = Object.getPrototypeOf(this); + if (Object.setPrototypeOf) { + Object.setPrototypeOf(instance, proto); + } else { + instance.__proto__ = proto; // eslint-disable-line no-proto + } + return instance; } inherits(MyError, Error); @@ -140,4 +146,16 @@ describe('Error type', function() { }); }); }); + + describe('when comparing Error objects with differing enumerable keys', () => { + it('should not break', () => { + var e1 = new Error('foo'); + var e2 = new Error(); + e2.message = 'foo'; + + expect(() => { + expect(e1, 'to equal', e2); + }, 'not to throw'); + }); + }); }); From 87296bcc16b80d74fe45d89a66e61d07477894d4 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Wed, 5 Sep 2018 20:59:40 +0200 Subject: [PATCH 07/34] Travis: Drop node.js < 6 support --- .travis.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 20cee0f92..4709eab55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,8 @@ language: node_js node_js: - - "0.10" - - "0.12" - - "4" - - "5" - - "6" - - "7" - - "8.4.0" - - "9" - - "10" -script: "make travis" + - '6' + - '7' + - '8.4.0' + - '9' + - '10' +script: 'make travis' From 3dfdeeb38f176bb17773730f689bff64b11b615b Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Sat, 15 Jul 2017 16:02:53 +0200 Subject: [PATCH 08/34] Drop compatibility with pre-10.10.0 type.diff return values The diff method used to return { inline: , diff: }, but that was changed in e22bdef68 with a backwards compatibility hack that installed a self-referencing 'diff' property. I suggest we remove the backwards compatibility in Unexpected 11. --- lib/Unexpected.js | 35 +++++++++----------- lib/UnexpectedError.js | 15 ++++----- lib/makeDiffResultBackwardsCompatible.js | 19 ----------- test/api/addType.spec.js | 42 ------------------------ test/api/fail.spec.js | 21 ------------ 5 files changed, 21 insertions(+), 111 deletions(-) delete mode 100644 lib/makeDiffResultBackwardsCompatible.js diff --git a/lib/Unexpected.js b/lib/Unexpected.js index bef52f2dc..a2597c51f 100644 --- a/lib/Unexpected.js +++ b/lib/Unexpected.js @@ -13,7 +13,6 @@ const defaultDepth = require('./defaultDepth'); const createWrappedExpectProto = require('./createWrappedExpectProto'); const AssertionString = require('./AssertionString'); const throwIfNonUnexpectedError = require('./throwIfNonUnexpectedError'); -const makeDiffResultBackwardsCompatible = require('./makeDiffResultBackwardsCompatible'); function isAssertionArg({ type }) { return type.is('assertion'); @@ -817,15 +816,13 @@ Unexpected.prototype.addType = function(type, childUnexpected) { ); } - return makeDiffResultBackwardsCompatible( - baseType.diff( - actual, - expected, - output.clone(), - (actual, expected) => that.diff(actual, expected, output.clone()), - (value, depth) => output.clone().appendInspected(value, depth), - that.equal.bind(that) - ) + return baseType.diff( + actual, + expected, + output.clone(), + (actual, expected) => that.diff(actual, expected, output.clone()), + (value, depth) => output.clone().appendInspected(value, depth), + that.equal.bind(that) ); }; @@ -1586,16 +1583,14 @@ Unexpected.prototype.diff = function( seen.push(a); } - return makeDiffResultBackwardsCompatible( - this.findCommonType(a, b).diff( - a, - b, - output, - (actual, expected) => - that.diff(actual, expected, output.clone(), recursions - 1, seen), - (v, depth) => output.clone().appendInspected(v, depth), - (actual, expected) => that.equal(actual, expected) - ) + return this.findCommonType(a, b).diff( + a, + b, + output, + (actual, expected) => + that.diff(actual, expected, output.clone(), recursions - 1, seen), + (v, depth) => output.clone().appendInspected(v, depth), + (actual, expected) => that.equal(actual, expected) ); }; diff --git a/lib/UnexpectedError.js b/lib/UnexpectedError.js index b5cead743..24acec176 100644 --- a/lib/UnexpectedError.js +++ b/lib/UnexpectedError.js @@ -1,7 +1,6 @@ const utils = require('./utils'); const defaultDepth = require('./defaultDepth'); const useFullStackTrace = require('./useFullStackTrace'); -const makeDiffResultBackwardsCompatible = require('./makeDiffResultBackwardsCompatible'); const errorMethodBlacklist = [ 'message', @@ -71,14 +70,12 @@ UnexpectedError.prototype.buildDiff = function(options) { const expect = this.expect; return ( this.createDiff && - makeDiffResultBackwardsCompatible( - this.createDiff( - output, - (actual, expected) => expect.diff(actual, expected, output.clone()), - (v, depth) => - output.clone().appendInspected(v, (depth || defaultDepth) - 1), - (actual, expected) => expect.equal(actual, expected) - ) + this.createDiff( + output, + (actual, expected) => expect.diff(actual, expected, output.clone()), + (v, depth) => + output.clone().appendInspected(v, (depth || defaultDepth) - 1), + (actual, expected) => expect.equal(actual, expected) ) ); }; diff --git a/lib/makeDiffResultBackwardsCompatible.js b/lib/makeDiffResultBackwardsCompatible.js deleted file mode 100644 index 379a1928f..000000000 --- a/lib/makeDiffResultBackwardsCompatible.js +++ /dev/null @@ -1,19 +0,0 @@ -module.exports = function makeDiffResultBackwardsCompatible(diff) { - if (diff) { - if (diff.isMagicPen) { - // New format: { [MagicPen], inline: } - // Make backwards compatible by adding a 'diff' property that points - // to the instance itself. - diff.diff = diff; - } else { - // Old format: { inline: , diff: } - // Upgrade to the new format by moving the inline property to - // the magicpen instance, and remain backwards compatibly by adding - // the diff property pointing to the instance itself. - diff.diff.inline = diff.inline; - diff = diff.diff; - diff.diff = diff; - } - } - return diff; -}; diff --git a/test/api/addType.spec.js b/test/api/addType.spec.js index 56d7de1bd..287e8cb1f 100644 --- a/test/api/addType.spec.js +++ b/test/api/addType.spec.js @@ -220,48 +220,6 @@ describe('addType', function() { ); }); }); - - it('allows adding a type whose diff method returns an old-style { inline: , diff: } object', function() { - clonedExpect.addType({ - name: 'box', - identify(obj) { - return obj && typeof obj === 'object' && obj.isBox; - }, - equal(a, b, equal) { - return a === b || equal(a.value, b.value); - }, - inspect(obj, depth, output, inspect) { - return output - .text('box(') - .append(inspect(obj.value)) - .text(')'); - }, - diff(actual, expected, output, diff) { - return { - inline: true, - diff: output - .text('box(') - .append(diff({ value: actual.value }, { value: expected.value })) - .text(')') - }; - } - }); - - expect( - function() { - clonedExpect(box('abc'), 'to equal', box('abe')); - }, - 'to throw', - "expected box('abc') to equal box('abe')\n" + - '\n' + - 'box({\n' + - " value: 'abc' // should equal 'abe'\n" + - ' //\n' + - ' // -abc\n' + - ' // +abe\n' + - '})' - ); - }); }); describe('#inspect', function() { diff --git a/test/api/fail.spec.js b/test/api/fail.spec.js index d10d374ea..0b7b3869b 100644 --- a/test/api/fail.spec.js +++ b/test/api/fail.spec.js @@ -150,26 +150,5 @@ describe('fail assertion', function() { "expected 'bar' to foo\n" + '\n' + 'custom' ); }); - - it('should support a diff function that uses the old API', function() { - var clonedExpect = expect.clone(); - clonedExpect.addAssertion(' to foo', function(expect, subject) { - expect.fail({ - diff(output, diff, inspect, equal) { - return { - inline: false, - diff: output.text('custom') - }; - } - }); - }); - expect( - function() { - clonedExpect('bar', 'to foo'); - }, - 'to throw', - "expected 'bar' to foo\n" + '\n' + 'custom' - ); - }); }); }); From becb8267eb54521f6f750d97f489afaf4b78e8c3 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Wed, 5 Sep 2018 21:47:51 +0200 Subject: [PATCH 09/34] Remove node.js >= 6 guard in the jest external tests --- test/external.spec.js | 268 ++++++++++++++++++++---------------------- 1 file changed, 130 insertions(+), 138 deletions(-) diff --git a/test/external.spec.js b/test/external.spec.js index 40b82cd8e..74eef4fd9 100644 --- a/test/external.spec.js +++ b/test/external.spec.js @@ -245,44 +245,122 @@ if (typeof process === 'object') { }); }); - // jest requires node.js 6 or above: - if (!/^v[012345]\./.test(process.version)) { - describe('executed through jest', function() { - expect.addAssertion( - ' executed through jest ', - function(expect, subject, env) { - if (!Array.isArray(subject)) { - subject = [subject]; - } - return expect.promise(function(run) { - childProcess.execFile( - pathModule.resolve(basePath, 'node_modules', '.bin', 'jest'), - [ - '--config', - pathModule.resolve(externaltestsDir, 'jestconfig.json') - ].concat( - subject.map(function(fileName) { - return pathModule.resolve( - externaltestsDir, - `${fileName}.spec.js` - ); - }) - ), - { - cwd: basePath, - env: extend({}, process.env, env || {}) - }, - run(function(err, stdout, stderr) { - return [err, stdout, stderr]; - }) - ); - }); + describe('executed through jest', function() { + expect.addAssertion( + ' executed through jest ', + function(expect, subject, env) { + if (!Array.isArray(subject)) { + subject = [subject]; } - ); + return expect.promise(function(run) { + childProcess.execFile( + pathModule.resolve(basePath, 'node_modules', '.bin', 'jest'), + [ + '--config', + pathModule.resolve(externaltestsDir, 'jestconfig.json') + ].concat( + subject.map(function(fileName) { + return pathModule.resolve( + externaltestsDir, + `${fileName}.spec.js` + ); + }) + ), + { + cwd: basePath, + env: extend({}, process.env, env || {}) + }, + run(function(err, stdout, stderr) { + return [err, stdout, stderr]; + }) + ); + }); + } + ); + + it('should report that a promise was created, but not returned by the it block', function() { + return expect( + 'forgotToReturnPendingPromiseFromSuccessfulItBlock', + 'executed through jest' + ).spread(function(err, stdout, stderr) { + expect( + stderr, + 'to contain', + 'should call the callback: You have created a promise that was not returned from the it block' + ); + expect(err, 'to satisfy', { code: 1 }); + }); + }); + + it('should not report that a promise was created if the test already failed synchronously', function() { + return expect( + 'forgotToReturnPendingPromiseFromFailingItBlock', + 'executed through jest' + ).spread(function(err, stdout, stderr) { + expect( + stderr, + 'not to contain', + 'should call the callback: You have created a promise that was not returned from the it block' + ); + expect(err, 'to satisfy', { code: 1 }); + }); + }); + + it('should trim unexpected plugins from the stack trace when the UNEXPECTED_FULL_TRACE environment variable is not set', function() { + return expect('fullTrace', 'executed through jest', { + UNEXPECTED_FULL_TRACE: '' + }).spread(function(err, stdout, stderr) { + expect(stderr, 'not to contain', 'node_modules/unexpected-bogus/'); + expect(err, 'to satisfy', { code: 1 }); + }); + }); + + it('should not trim unexpected plugins from the stack trace when the UNEXPECTED_FULL_TRACE environment variable is set', function() { + return expect('fullTrace', 'executed through jest', { + UNEXPECTED_FULL_TRACE: 'yes' + }).spread(function(err, stdout, stderr) { + expect(stderr, 'to contain', 'node_modules/unexpected-bogus/'); + expect(err, 'to satisfy', { code: 1 }); + }); + }); + + it('should accept an UNEXPECTED_DEPTH environment variable', function() { + return expect('deepObject', 'executed through jest', { + UNEXPECTED_DEPTH: 6 + }).spread(function(err, stdout, stderr) { + expect(err, 'to be falsy'); + }); + }); - it('should report that a promise was created, but not returned by the it block', function() { + it('should render a long stack trace for an async test', function() { + return expect('failingAsync', 'executed through jest').spread(function( + err, + stdout, + stderr + ) { + expect(err, 'to be truthy'); + expect(stderr, 'to contain', 'From previous event:'); + }); + }); + + it('should fail when a promise failing in the next tick is created but not returned', function() { + return expect( + 'forgotToReturnPromiseRejectedInTheNextTick', + 'executed through jest' + ).spread(function(err, stdout, stderr) { + expect( + stderr, + 'to contain', + 'should fail: You have created a promise that was not returned from the it block' + ); + expect(err, 'to satisfy', { code: 1 }); + }); + }); + + describe('with a test suite spanning multiple files', function() { + it('should report that a promise was created, but not returned by the it block in the first test', function() { return expect( - 'forgotToReturnPendingPromiseFromSuccessfulItBlock', + ['forgotToReturnPendingPromiseFromSuccessfulItBlock', 'successful'], 'executed through jest' ).spread(function(err, stdout, stderr) { expect( @@ -294,126 +372,40 @@ if (typeof process === 'object') { }); }); - it('should not report that a promise was created if the test already failed synchronously', function() { + it('should report that a promise was created, but not returned by the it block in the second test', function() { return expect( - 'forgotToReturnPendingPromiseFromFailingItBlock', + ['successful', 'forgotToReturnPendingPromiseFromSuccessfulItBlock'], 'executed through jest' ).spread(function(err, stdout, stderr) { expect( stderr, - 'not to contain', + 'to contain', 'should call the callback: You have created a promise that was not returned from the it block' ); expect(err, 'to satisfy', { code: 1 }); }); }); + }); - it('should trim unexpected plugins from the stack trace when the UNEXPECTED_FULL_TRACE environment variable is not set', function() { - return expect('fullTrace', 'executed through jest', { - UNEXPECTED_FULL_TRACE: '' - }).spread(function(err, stdout, stderr) { - expect(stderr, 'not to contain', 'node_modules/unexpected-bogus/'); - expect(err, 'to satisfy', { code: 1 }); - }); - }); - - it('should not trim unexpected plugins from the stack trace when the UNEXPECTED_FULL_TRACE environment variable is set', function() { - return expect('fullTrace', 'executed through jest', { - UNEXPECTED_FULL_TRACE: 'yes' - }).spread(function(err, stdout, stderr) { - expect(stderr, 'to contain', 'node_modules/unexpected-bogus/'); - expect(err, 'to satisfy', { code: 1 }); - }); - }); - - it('should accept an UNEXPECTED_DEPTH environment variable', function() { - return expect('deepObject', 'executed through jest', { - UNEXPECTED_DEPTH: 6 - }).spread(function(err, stdout, stderr) { - expect(err, 'to be falsy'); - }); - }); - - it('should render a long stack trace for an async test', function() { - return expect('failingAsync', 'executed through jest').spread( - function(err, stdout, stderr) { - expect(err, 'to be truthy'); - expect(stderr, 'to contain', 'From previous event:'); - } - ); - }); - - it('should fail when a promise failing in the next tick is created but not returned', function() { + describe('with an assertion that succeeds, but creates a promise that remains pending', function() { + it('should pass', function() { return expect( - 'forgotToReturnPromiseRejectedInTheNextTick', + 'assertionSucceedsWhilePromiseIsPending', 'executed through jest' ).spread(function(err, stdout, stderr) { expect( stderr, - 'to contain', - 'should fail: You have created a promise that was not returned from the it block' + 'not to contain', + 'should call the callback: You have created a promise that was not returned from the it block' ); - expect(err, 'to satisfy', { code: 1 }); - }); - }); - - describe('with a test suite spanning multiple files', function() { - it('should report that a promise was created, but not returned by the it block in the first test', function() { - return expect( - [ - 'forgotToReturnPendingPromiseFromSuccessfulItBlock', - 'successful' - ], - 'executed through jest' - ).spread(function(err, stdout, stderr) { - expect( - stderr, - 'to contain', - 'should call the callback: You have created a promise that was not returned from the it block' - ); - expect(err, 'to satisfy', { code: 1 }); - }); - }); - - it('should report that a promise was created, but not returned by the it block in the second test', function() { - return expect( - [ - 'successful', - 'forgotToReturnPendingPromiseFromSuccessfulItBlock' - ], - 'executed through jest' - ).spread(function(err, stdout, stderr) { - expect( - stderr, - 'to contain', - 'should call the callback: You have created a promise that was not returned from the it block' - ); - expect(err, 'to satisfy', { code: 1 }); - }); - }); - }); - - describe('with an assertion that succeeds, but creates a promise that remains pending', function() { - it('should pass', function() { - return expect( - 'assertionSucceedsWhilePromiseIsPending', - 'executed through jest' - ).spread(function(err, stdout, stderr) { - expect( - stderr, - 'not to contain', - 'should call the callback: You have created a promise that was not returned from the it block' - ); - expect(err, 'to be falsy'); - }); + expect(err, 'to be falsy'); }); }); + }); - it('should render the stack trace of the thrown error without any artifacts when "not to error" encounters an error', function() { - return expect( - 'notToErrorCaughtError', - 'executed through jest' - ).spread(function(err, stdout, stderr) { + it('should render the stack trace of the thrown error without any artifacts when "not to error" encounters an error', function() { + return expect('notToErrorCaughtError', 'executed through jest').spread( + function(err, stdout, stderr) { expect(err, 'to satisfy', { code: 1 }); expect( stderr, @@ -421,9 +413,9 @@ if (typeof process === 'object') { ' not to error\n' + " returned promise rejected with: Error('argh')\n" ).and('to contain', ' at thisIsImportant'); - }); - }); + } + ); }); - } + }); }); } From e0c3bf5a557b24699af1da843f57e5553a3207cf Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Wed, 5 Sep 2018 21:49:05 +0200 Subject: [PATCH 10/34] Remove node.js < 3 guard from function tests --- test/types/function-type.spec.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/types/function-type.spec.js b/test/types/function-type.spec.js index d869ac94c..473c07614 100644 --- a/test/types/function-type.spec.js +++ b/test/types/function-type.spec.js @@ -14,11 +14,9 @@ describe('function type', function() { expect(fn, 'to inspect as', 'function foo() {}'); }); - var isNodeJs3OrBelow = - typeof process === 'object' && /^v[0123]\./.test(process.version); var isPhantomJs = typeof navigator !== 'undefined' && /phantom/i.test(navigator.userAgent); - if (!isNodeJs3OrBelow && !isPhantomJs) { + if (!isPhantomJs) { // Node.js 3 and below and phantom.js don't include "bound " and the // old Phantom.js version that's currently available on Travis doesn't // even have Function#bind, which we then polyfill via es5-shim, leading From 961ae3855b763a2fa3dafa4ee89f37df49802c82 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Wed, 5 Sep 2018 21:51:40 +0200 Subject: [PATCH 11/34] Remove jest version check, assume that it works now that we only support node 6+ --- Makefile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 45f92c34d..4774f519f 100644 --- a/Makefile +++ b/Makefile @@ -68,9 +68,6 @@ else ./node_modules/.bin/jest -c test/jest.es5.config.json endif -test-jest-if-supported-node-version: - @node-version-gte-6 && make test-jest || echo Skipping, jest is unsupported with node $(shell node --version) - .PHONY: test test: test-sources @./node_modules/.bin/mocha --opts $(MOCHA_OPTS) $(TEST_SOURCES) $(TEST_SOURCE_MARKDOWN) @@ -93,7 +90,7 @@ test-browser: create-html-runners ${TARGETS} @./node_modules/.bin/serve . .PHONY: travis-secondary -travis-secondary: clean test test-jest-if-supported-node-version coverage +travis-secondary: clean test test-jest coverage .PHONY: travis-main travis-main: clean lint test test-jasmine test-jest coverage @@ -134,7 +131,7 @@ changelog: git-dirty-check fi .PHONY: release-% -release-%: git-dirty-check lint ${TARGETS} test-phantomjs test-jasmine test-jest-if-supported-node-version commit-unexpected deploy-site +release-%: git-dirty-check lint ${TARGETS} test-phantomjs test-jasmine test-jest commit-unexpected deploy-site IS_MAKE_RELEASE=yes npm version $* make changelog @echo $* release ready to be publised to NPM From ecf4e76bb7fc36b9206a260b0a0960930d11778d Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Wed, 5 Sep 2018 20:20:39 +0000 Subject: [PATCH 12/34] Update rollup-plugin-uglify to version 5.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 62fe667ef..a9bf6a4b5 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "rollup-plugin-commonjs": "^9.1.0", "rollup-plugin-node-globals": "^1.1.0", "rollup-plugin-node-resolve": "^3.0.0", - "rollup-plugin-uglify": "^4.0.0", + "rollup-plugin-uglify": "^5.0.2", "rsvp": "^4.7.0", "serve": "*", "unexpected-documentation-site-generator": "^4.6.1", From 0f6fdb63c7c55ed5b187cff11e09d7c6fdb3b868 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Wed, 5 Sep 2018 22:27:49 +0200 Subject: [PATCH 13/34] Fix jest invocation for non-modern nodes (6-7) --- Makefile | 2 +- test/jest.es5.config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4774f519f..98aed4b21 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ test-jest: ifeq ($(MODERN_NODE), true) ./node_modules/.bin/jest else - ./node_modules/.bin/jest -c test/jest.es5.config.json + ./node_modules/.bin/jest --rootDir . -c test/jest.es5.config.json endif .PHONY: test diff --git a/test/jest.es5.config.json b/test/jest.es5.config.json index 8d7d2ac5e..02a063955 100644 --- a/test/jest.es5.config.json +++ b/test/jest.es5.config.json @@ -1,5 +1,5 @@ { - "setupFiles": ["/build/test/promisePolyfill"], + "setupFiles": ["/build/test/promisePolyfill.js"], "setupTestFrameworkScriptFile": "/build/test/common.js", "testMatch": ["/build/test/**.spec.js"] } From 00c2f3474e06b074665459f6e563239375c8843b Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Sun, 16 Sep 2018 04:25:23 +0000 Subject: [PATCH 14/34] Update eslint to version 5.6.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7d32e873d..1df9c9f3c 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "babel-preset-es2015-without-strict": "^0.0.4", "coveralls": "^3.0.0", "es5-shim": "^4.5.9", - "eslint": "^5.5.0", + "eslint": "^5.6.0", "eslint-config-pretty-standard": "^2.0.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-prettier": "^2.6.0", From 1b5d97e5ff5305b9528fbbe8890e9a64e27a02fb Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Mon, 17 Sep 2018 06:35:12 +0000 Subject: [PATCH 15/34] Update gh-pages to version 2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1df9c9f3c..3258e53fc 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "eslint-plugin-import": "^2.8.0", "eslint-plugin-prettier": "^2.6.0", "find-node-modules": "^1.0.4", - "gh-pages": "^1.1.0", + "gh-pages": "^2.0.0", "istanbul": "^0.4.5", "jasmine": "^3.1.0", "jasmine-core": "^3.1.0", From 2df1367c6db7b79ee71bb91547c192a01d230c2c Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Mon, 17 Sep 2018 10:25:12 +0000 Subject: [PATCH 16/34] Update rollup to version 0.66.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3258e53fc..257fe626a 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "nyc": "^13.0.1", "offline-github-changelog": "^1.2.0", "prettier": "~1.14.0", - "rollup": "^0.65.1", + "rollup": "^0.66.0", "rollup-plugin-commonjs": "^9.1.0", "rollup-plugin-node-globals": "^1.1.0", "rollup-plugin-node-resolve": "^3.0.0", From e0febfeee2fb28f7348c735ae1a5e1e6b48b8dcf Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Mon, 17 Sep 2018 15:25:21 +0000 Subject: [PATCH 17/34] Update rollup-plugin-uglify to version 6.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 257fe626a..8b98cde3d 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "rollup-plugin-commonjs": "^9.1.0", "rollup-plugin-node-globals": "^1.1.0", "rollup-plugin-node-resolve": "^3.0.0", - "rollup-plugin-uglify": "^5.0.2", + "rollup-plugin-uglify": "^6.0.0", "rsvp": "^4.7.0", "serve": "*", "unexpected-documentation-site-generator": "^4.6.1", From f1e6a58456d823133c0c8cafc212fa8ef12e1891 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Fri, 28 Sep 2018 19:51:08 +0200 Subject: [PATCH 18/34] Remember to .clone() in some of the external tests --- externaltests/assertionSucceedsWhilePromiseIsPending.spec.js | 2 +- externaltests/failingAsync.spec.js | 2 +- .../forgotToReturnPromiseRejectedInTheNextTick.spec.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/externaltests/assertionSucceedsWhilePromiseIsPending.spec.js b/externaltests/assertionSucceedsWhilePromiseIsPending.spec.js index a1303ac6d..6d87b2fb3 100644 --- a/externaltests/assertionSucceedsWhilePromiseIsPending.spec.js +++ b/externaltests/assertionSucceedsWhilePromiseIsPending.spec.js @@ -1,4 +1,4 @@ -var expect = require('../lib'); +var expect = require('../lib').clone(); expect.addAssertion(' to bar', function(expect, subject) { expect(subject, 'to equal', 'bar'); diff --git a/externaltests/failingAsync.spec.js b/externaltests/failingAsync.spec.js index c05be2e7c..24781cb06 100644 --- a/externaltests/failingAsync.spec.js +++ b/externaltests/failingAsync.spec.js @@ -1,4 +1,4 @@ -var expect = require('../lib'); +var expect = require('../lib').clone(); expect.addAssertion(' when delayed a little bit ', function( expect, diff --git a/externaltests/forgotToReturnPromiseRejectedInTheNextTick.spec.js b/externaltests/forgotToReturnPromiseRejectedInTheNextTick.spec.js index 821dae9e9..7e0d4ef7b 100644 --- a/externaltests/forgotToReturnPromiseRejectedInTheNextTick.spec.js +++ b/externaltests/forgotToReturnPromiseRejectedInTheNextTick.spec.js @@ -1,4 +1,4 @@ -var expect = require('../lib'); +var expect = require('../lib').clone(); it('should fail', function() { expect.addAssertion(' to foo', function(expect, subject) { From 2fad29f147bd2f223db1f0cd7754119809279ab7 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Fri, 28 Sep 2018 19:52:50 +0200 Subject: [PATCH 19/34] Freeze the top level expect As discussed on #476 [semver-major] --- lib/index.js | 3 ++- test/unexpected.spec.js | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index de1ff88ce..f825a7bc3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,7 +2,8 @@ module.exports = require('./Unexpected') .create() .use(require('./styles')) .use(require('./types')) - .use(require('./assertions')); + .use(require('./assertions')) + .freeze(); // Add an inspect method to all the promises we return that will make the REPL, console.log, and util.inspect render it nicely in node.js: require('unexpected-bluebird').prototype.inspect = function() { diff --git a/test/unexpected.spec.js b/test/unexpected.spec.js index 23a4d3125..320f8f5e5 100644 --- a/test/unexpected.spec.js +++ b/test/unexpected.spec.js @@ -1,4 +1,4 @@ -/*global unexpected*/ +/*global unexpected, weknowhow*/ it.skipIf = function(condition) { (condition ? it.skip : it).apply( @@ -10,6 +10,19 @@ it.skipIf = function(condition) { describe('unexpected', function() { var expect = unexpected.clone(); + it('should freeze the top-level unexpected instance', function() { + const topLevelExpect = + typeof weknowhow === 'undefined' ? require('../lib/') : weknowhow.expect; + + expect( + function() { + topLevelExpect.addAssertion(' to foo', function() {}); + }, + 'to throw', + 'Cannot add an assertion to a frozen instance, please run .clone() first' + ); + }); + describe('argument validation', function() { it('fails when given no parameters', function() { expect( From a469d8977f39a7140caa44238f142a51b20ef62f Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Sat, 29 Sep 2018 21:09:08 +0200 Subject: [PATCH 20/34] Convert new/changed tests to use arrow functions. perl -pi -e 's/^(\s*(?:beforeEach|before|after|afterEach).*)function\(\) \{$/$1() => {/g;' `find test externaltests -name '*.js'` perl -pi -e 's/^(\s*(?:describe|it).*, )function\(\) \{$/$1() => {/g;' `find test externaltests -name '*.js'` --- test/assertions/to-satisfy.spec.js | 4 ++-- test/external.spec.js | 28 ++++++++++++++-------------- test/unexpected.spec.js | 6 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/test/assertions/to-satisfy.spec.js b/test/assertions/to-satisfy.spec.js index 32ab1fcfd..0006efb88 100644 --- a/test/assertions/to-satisfy.spec.js +++ b/test/assertions/to-satisfy.spec.js @@ -2210,8 +2210,8 @@ describe('to satisfy assertion', () => { }); }); - describe('when not matching the non-enumerable property', function() { - it('should fail with a diff', function() { + describe('when not matching the non-enumerable property', () => { + it('should fail with a diff', () => { expect( function() { expect(bar, 'to exhaustively satisfy', { diff --git a/test/external.spec.js b/test/external.spec.js index 15207f7a9..650b6c4a1 100644 --- a/test/external.spec.js +++ b/test/external.spec.js @@ -245,7 +245,7 @@ if (typeof process === 'object') { }); }); - describe('executed through jest', function() { + describe('executed through jest', () => { expect.addAssertion( ' executed through jest ', function(expect, subject, env) { @@ -278,7 +278,7 @@ if (typeof process === 'object') { } ); - it('should report that a promise was created, but not returned by the it block', function() { + it('should report that a promise was created, but not returned by the it block', () => { return expect( 'forgotToReturnPendingPromiseFromSuccessfulItBlock', 'executed through jest' @@ -292,7 +292,7 @@ if (typeof process === 'object') { }); }); - it('should not report that a promise was created if the test already failed synchronously', function() { + it('should not report that a promise was created if the test already failed synchronously', () => { return expect( 'forgotToReturnPendingPromiseFromFailingItBlock', 'executed through jest' @@ -306,7 +306,7 @@ if (typeof process === 'object') { }); }); - it('should trim unexpected plugins from the stack trace when the UNEXPECTED_FULL_TRACE environment variable is not set', function() { + it('should trim unexpected plugins from the stack trace when the UNEXPECTED_FULL_TRACE environment variable is not set', () => { return expect('fullTrace', 'executed through jest', { UNEXPECTED_FULL_TRACE: '' }).spread(function(err, stdout, stderr) { @@ -315,7 +315,7 @@ if (typeof process === 'object') { }); }); - it('should not trim unexpected plugins from the stack trace when the UNEXPECTED_FULL_TRACE environment variable is set', function() { + it('should not trim unexpected plugins from the stack trace when the UNEXPECTED_FULL_TRACE environment variable is set', () => { return expect('fullTrace', 'executed through jest', { UNEXPECTED_FULL_TRACE: 'yes' }).spread(function(err, stdout, stderr) { @@ -324,7 +324,7 @@ if (typeof process === 'object') { }); }); - it('should accept an UNEXPECTED_DEPTH environment variable', function() { + it('should accept an UNEXPECTED_DEPTH environment variable', () => { return expect('deepObject', 'executed through jest', { UNEXPECTED_DEPTH: 6 }).spread(function(err, stdout, stderr) { @@ -332,7 +332,7 @@ if (typeof process === 'object') { }); }); - it('should render a long stack trace for an async test', function() { + it('should render a long stack trace for an async test', () => { return expect('failingAsync', 'executed through jest').spread(function( err, stdout, @@ -343,7 +343,7 @@ if (typeof process === 'object') { }); }); - it('should fail when a promise failing in the next tick is created but not returned', function() { + it('should fail when a promise failing in the next tick is created but not returned', () => { return expect( 'forgotToReturnPromiseRejectedInTheNextTick', 'executed through jest' @@ -357,8 +357,8 @@ if (typeof process === 'object') { }); }); - describe('with a test suite spanning multiple files', function() { - it('should report that a promise was created, but not returned by the it block in the first test', function() { + describe('with a test suite spanning multiple files', () => { + it('should report that a promise was created, but not returned by the it block in the first test', () => { return expect( ['forgotToReturnPendingPromiseFromSuccessfulItBlock', 'successful'], 'executed through jest' @@ -372,7 +372,7 @@ if (typeof process === 'object') { }); }); - it('should report that a promise was created, but not returned by the it block in the second test', function() { + it('should report that a promise was created, but not returned by the it block in the second test', () => { return expect( ['successful', 'forgotToReturnPendingPromiseFromSuccessfulItBlock'], 'executed through jest' @@ -387,8 +387,8 @@ if (typeof process === 'object') { }); }); - describe('with an assertion that succeeds, but creates a promise that remains pending', function() { - it('should pass', function() { + describe('with an assertion that succeeds, but creates a promise that remains pending', () => { + it('should pass', () => { return expect( 'assertionSucceedsWhilePromiseIsPending', 'executed through jest' @@ -403,7 +403,7 @@ if (typeof process === 'object') { }); }); - it('should render the stack trace of the thrown error without any artifacts when "not to error" encounters an error', function() { + it('should render the stack trace of the thrown error without any artifacts when "not to error" encounters an error', () => { return expect('notToErrorCaughtError', 'executed through jest').spread( function(err, stdout, stderr) { expect(err, 'to satisfy', { code: 1 }); diff --git a/test/unexpected.spec.js b/test/unexpected.spec.js index a229cbedb..19944c48b 100644 --- a/test/unexpected.spec.js +++ b/test/unexpected.spec.js @@ -10,7 +10,7 @@ it.skipIf = function(condition) { describe('unexpected', () => { var expect = unexpected.clone(); - it('should freeze the top-level unexpected instance', function() { + it('should freeze the top-level unexpected instance', () => { const topLevelExpect = typeof weknowhow === 'undefined' ? require('../lib/') : weknowhow.expect; @@ -23,8 +23,8 @@ describe('unexpected', () => { ); }); - describe('argument validation', function() { - it('fails when given no parameters', function() { + describe('argument validation', () => { + it('fails when given no parameters', () => { expect( function() { expect(); From 89d19ed1a1a7e11568ec59e6badd22a9e96a190c Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Sat, 29 Sep 2018 19:40:12 +0000 Subject: [PATCH 21/34] Update eslint to version 5.6.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d2eca6aef..b935fdf4e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "babel-preset-es2015-without-strict": "^0.0.4", "coveralls": "^3.0.0", "es5-shim": "^4.5.9", - "eslint": "^4.17.0", + "eslint": "^5.6.1", "eslint-config-pretty-standard": "^1.2.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-mocha": "^5.2.0", From 930431ca55d7260d8ea450a0a95d6c271bb05d75 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Tue, 17 Apr 2018 10:40:59 +0200 Subject: [PATCH 22/34] Make expect({foo: }, 'to satisfy', {foo: }) compare the functions with === instead of executing the RHS one with the LHS one as the argument. (Breaking!) --- lib/Unexpected.js | 4 +-- lib/assertions.js | 20 +++++++----- test/assertions/to-satisfy.spec.js | 52 +++++++++++++++++++++++------- 3 files changed, 54 insertions(+), 22 deletions(-) diff --git a/lib/Unexpected.js b/lib/Unexpected.js index a2597c51f..04f72e2fe 100644 --- a/lib/Unexpected.js +++ b/lib/Unexpected.js @@ -1326,7 +1326,7 @@ Unexpected.prototype._expect = function expect(context, args) { if (args.length < 2) { throw new Error('The expect function requires at least two parameters.'); - } else if (testDescriptionString && testDescriptionString._expectIt) { + } else if (typeof testDescriptionString === 'function') { return that.expect.withError( () => testDescriptionString(subject), err => { @@ -1401,7 +1401,7 @@ Unexpected.prototype._expect = function expect(context, args) { wrappedExpect, subject ); - } else if (testDescriptionString && testDescriptionString._expectIt) { + } else if (typeof testDescriptionString === 'function') { wrappedExpect.errorMode = 'nested'; return wrappedExpect.withError( () => testDescriptionString(subject), diff --git a/lib/assertions.js b/lib/assertions.js index 8bc22912a..4d88f1bc7 100644 --- a/lib/assertions.js +++ b/lib/assertions.js @@ -1094,10 +1094,14 @@ module.exports = expect => { const expected = {}; keys.forEach((key, index) => { if (typeof nextArg === 'string') { - expected[key] = s => expect.shift(s); + expected[key] = expect.it(s => expect.shift(s)); } else if (typeof nextArg === 'function') { - expected[key] = s => - nextArg._expectIt ? nextArg(s, expect.context) : nextArg(s, index); + expected[key] = expect.it( + (s, context) => + nextArg._expectIt + ? nextArg(s, context) + : expect.it(s => nextArg(s, index))(s) + ); } else { expected[key] = nextArg; } @@ -1504,7 +1508,7 @@ module.exports = expect => { const valueKey = valueType.valueForKey(value, keyInValue); const valueKeyType = expect.findTypeOf(valueKey); - if (valueKeyType.is('function')) { + if (valueKeyType.is('expect.it')) { return valueKey(subjectKey); } else { return expect(subjectKey, 'to [exhaustively] satisfy', valueKey); @@ -1715,7 +1719,9 @@ module.exports = expect => { } else if (type === 'insert') { this.annotationBlock(function() { if ( - expect.findTypeOf(diffItem.value).is('function') + expect + .findTypeOf(diffItem.value) + .is('expect.it') ) { this.error('missing: ').block(function() { this.omitSubject = undefined; @@ -1867,8 +1873,6 @@ module.exports = expect => { if (valueKeyType.is('expect.it')) { expect.context.thisObject = subject; return valueKey(subjectKey, expect.context); - } else if (valueKeyType.is('function')) { - return valueKey(subjectKey); } else { return expect(subjectKey, 'to [exhaustively] satisfy', valueKey); } @@ -1941,7 +1945,7 @@ module.exports = expect => { conflicting = null; } } else if (!subjectType.hasKey(subject, key)) { - if (expect.findTypeOf(valueKey).is('function')) { + if (expect.findTypeOf(valueKey).is('expect.it')) { if (promiseByKey[key].isRejected()) { output.error('// missing:').sp(); valueOutput = output diff --git a/test/assertions/to-satisfy.spec.js b/test/assertions/to-satisfy.spec.js index 0006efb88..3e943fb56 100644 --- a/test/assertions/to-satisfy.spec.js +++ b/test/assertions/to-satisfy.spec.js @@ -2232,23 +2232,26 @@ describe('to satisfy assertion', () => { }); }); - // Debatable: - describe('when an unpresent value to is satisfied against a function', () => { - it('should allow an unpresent value to be satisfied against a non-expect.it function', () => { - expect({}, 'to satisfy', { foo: function() {} }); + describe('when an unpresent value to is satisfied against an expect.it function wrapper', () => { + it('should allow an unpresent value to be satisfied against the function', () => { + expect({}, 'to satisfy', { + foo: expect.it(v => { + expect(v, 'to be undefined'); + }) + }); }); it('should fail when the function throws', () => { expect( - function() { + () => { expect({}, 'to satisfy', { - foo(value) { + foo: expect.it(value => { expect(value, 'to be a string'); - } + }) }); }, 'to throw', - function(err) { + err => { // Compensate for V8 5.1+ setting { foo: function () {} }.foo.name === 'foo' // http://v8project.blogspot.dk/2016/04/v8-release-51.html expect( @@ -2271,7 +2274,7 @@ describe('to satisfy assertion', () => { it('should fail with a diff', () => { expect( - function() { + () => { expect({}, 'to satisfy', { foo: expect.it('to be a string') }); }, 'to throw', @@ -2287,7 +2290,12 @@ describe('to satisfy assertion', () => { it('should not break when the assertion fails and there is a fulfilled function in the RHS', () => { expect( function() { - expect({}, 'to satisfy', { bar: 123, foo: function() {} }); + expect({}, 'to satisfy', { + bar: 123, + foo: expect.it(v => { + expect(v, 'to be undefined'); + }) + }); }, 'to throw', function(err) { @@ -2299,17 +2307,37 @@ describe('to satisfy assertion', () => { .toString() .replace(/function foo/g, 'function '), 'to satisfy', - 'expected {} to satisfy { bar: 123, foo: function () {} }\n' + + 'expected {}\n' + + "to satisfy { bar: 123, foo: expect.it(v => { expect(v, 'to be undefined'); }) }\n" + '\n' + '{\n' + ' // missing bar: 123\n' + - ' // missing foo: should satisfy function () {}\n' + + " // missing foo: should satisfy expect.it(v => { expect(v, 'to be undefined'); })\n" + '}' ); } ); }); + it('should render a diff when the function differs', () => { + function myFunction() {} + function myOtherFunction() {} + + expect( + () => { + expect({ foo: myFunction }, 'to satisfy', { foo: myOtherFunction }); + }, + 'to throw', + 'expected { foo: function myFunction() {} }\n' + + 'to satisfy { foo: function myOtherFunction() {} }\n' + + '\n' + + '{\n' + + ' foo: function myFunction() {} // expected { foo: function myFunction() {} }\n' + + ' // to satisfy { foo: function myOtherFunction() {} }\n' + + '}' + ); + }); + describe('when matching the constructor property of an object', () => { function Foo() {} From b11b96b75a51a690af272d19eddf82e5a20037fd Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Sun, 30 Sep 2018 21:18:39 +0200 Subject: [PATCH 23/34] Simply expect.it handling --- lib/assertions.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/assertions.js b/lib/assertions.js index 4d88f1bc7..eedeb458a 100644 --- a/lib/assertions.js +++ b/lib/assertions.js @@ -1096,12 +1096,9 @@ module.exports = expect => { if (typeof nextArg === 'string') { expected[key] = expect.it(s => expect.shift(s)); } else if (typeof nextArg === 'function') { - expected[key] = expect.it( - (s, context) => - nextArg._expectIt - ? nextArg(s, context) - : expect.it(s => nextArg(s, index))(s) - ); + expected[key] = nextArg._expectIt + ? nextArg + : expect.it(s => nextArg(s, index)); } else { expected[key] = nextArg; } From 3e15f5b16d7f49917334c18906d148e39e14a994 Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Sun, 30 Sep 2018 21:32:33 +0200 Subject: [PATCH 24/34] Added a test for using an expect.it function wrapper in to satisfy --- test/assertions/to-satisfy.spec.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/assertions/to-satisfy.spec.js b/test/assertions/to-satisfy.spec.js index 3e943fb56..34e3e1ad1 100644 --- a/test/assertions/to-satisfy.spec.js +++ b/test/assertions/to-satisfy.spec.js @@ -680,6 +680,30 @@ describe('to satisfy assertion', () => { }); }); + describe('with a expect.it function wrapper', () => { + it("succeeds if the function doesn't throw", () => { + expect({ foo: 'bar' }, 'to satisfy', { + foo: expect.it(v => expect(v, 'to be a string')) + }); + }); + + it('should fail with an diff if the function fails', () => { + expect( + function() { + expect({ foo: 3 }, 'to satisfy', { + foo: expect.it(v => expect(v, 'to equal', 2)) + }); + }, + 'to throw', + "expected { foo: 3 } to satisfy { foo: expect.it(v => expect(v, 'to equal', 2)) }\n" + + '\n' + + '{\n' + + ' foo: 3 // should equal 2\n' + + '}' + ); + }); + }); + describe('with a synchronous expect.it in the RHS object', () => { it('should support an object with a property value of expect.it', () => { expect({ foo: 'bar' }, 'to satisfy', { From 8b0cd9d3b0aa679858d14bc3c65a59b3ab4d91af Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Sun, 30 Sep 2018 21:38:10 +0200 Subject: [PATCH 25/34] Fix output formatting in test --- test/assertions/to-satisfy.spec.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/assertions/to-satisfy.spec.js b/test/assertions/to-satisfy.spec.js index 34e3e1ad1..5200acaa6 100644 --- a/test/assertions/to-satisfy.spec.js +++ b/test/assertions/to-satisfy.spec.js @@ -691,11 +691,14 @@ describe('to satisfy assertion', () => { expect( function() { expect({ foo: 3 }, 'to satisfy', { - foo: expect.it(v => expect(v, 'to equal', 2)) + foo: expect.it(function(v) { + expect(v, 'to equal', 2); + }) }); }, 'to throw', - "expected { foo: 3 } to satisfy { foo: expect.it(v => expect(v, 'to equal', 2)) }\n" + + 'expected { foo: 3 }\n' + + "to satisfy { foo: expect.it(function (v) { expect(v, 'to equal', 2); }) }\n" + '\n' + '{\n' + ' foo: 3 // should equal 2\n' + @@ -2316,7 +2319,7 @@ describe('to satisfy assertion', () => { function() { expect({}, 'to satisfy', { bar: 123, - foo: expect.it(v => { + foo: expect.it(function(v) { expect(v, 'to be undefined'); }) }); @@ -2331,12 +2334,15 @@ describe('to satisfy assertion', () => { .toString() .replace(/function foo/g, 'function '), 'to satisfy', - 'expected {}\n' + - "to satisfy { bar: 123, foo: expect.it(v => { expect(v, 'to be undefined'); }) }\n" + + 'expected {} to satisfy\n' + + '{\n' + + ' bar: 123,\n' + + " foo: expect.it(function (v) { expect(v, 'to be undefined'); })\n" + + '}\n' + '\n' + '{\n' + ' // missing bar: 123\n' + - " // missing foo: should satisfy expect.it(v => { expect(v, 'to be undefined'); })\n" + + " // missing foo: should satisfy expect.it(function (v) { expect(v, 'to be undefined'); })\n" + '}' ); } From 40ed939c36162d71df39b24476fb2517e857073f Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Sun, 30 Sep 2018 23:20:45 +0200 Subject: [PATCH 26/34] Special case expect.it(subject => ...) --- lib/Unexpected.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/Unexpected.js b/lib/Unexpected.js index 04f72e2fe..ecdb5613f 100644 --- a/lib/Unexpected.js +++ b/lib/Unexpected.js @@ -234,6 +234,16 @@ function createExpectIt(unexpected, expectations) { ? context : new Context(unexpected); + if ( + orGroups.length === 1 && + orGroups[0].length === 1 && + orGroups[0][0].length === 1 && + typeof orGroups[0][0][0] === 'function' + ) { + // expect.it(subject => ...) + return oathbreaker(orGroups[0][0][0](subject)); + } + const groupEvaluations = []; const promises = []; orGroups.forEach(orGroup => { From f88bdf94ff88b305f97ce69269acda1cd755179b Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Tue, 2 Oct 2018 07:35:22 +0000 Subject: [PATCH 27/34] Update eslint-plugin-prettier to version 3.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b0939c8a..4464b6af0 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "eslint-config-pretty-standard": "^1.2.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-mocha": "^5.2.0", - "eslint-plugin-prettier": "^2.6.0", + "eslint-plugin-prettier": "^3.0.0", "find-node-modules": "^1.0.4", "gh-pages": "^1.1.0", "istanbul": "^0.4.5", From 98e08e2a99433f049046e10aca46b649aa06208f Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Tue, 2 Oct 2018 20:35:22 +0200 Subject: [PATCH 28/34] Added some more tests for the expect.it function wrapper --- test/api/it.spec.js | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/api/it.spec.js b/test/api/it.spec.js index 9b31e9129..db19293da 100644 --- a/test/api/it.spec.js +++ b/test/api/it.spec.js @@ -363,6 +363,19 @@ describe('expect.it', () => { ); }); + it('supports returning a promise from the function', () => { + return expect( + () => + expect.it(value => + expect.promise(run => { + setTimeout(run(() => expect(value, 'to equal', 'bar'))); + }) + )('foo'), + 'to be rejected with', + "expected 'foo' to equal 'bar'\n" + '\n' + '-foo\n' + '+bar' + ); + }); + it('should fail when passed more than two arguments', () => { expect( function() { @@ -374,5 +387,45 @@ describe('expect.it', () => { 'expect.it() does not accept additional arguments' ); }); + + describe('and chained the expression is chained', () => { + describe('and the first expression is a function', () => { + it('fails with a diff including all items in the chain', () => { + expect( + function() { + expect + .it(function(value) { + expect(value, 'to equal', 'bar'); + }) + .and('to be a string')('foo'); + }, + 'to throw', + "⨯ expected 'foo' to equal 'bar' and\n" + + '\n' + + ' -foo\n' + + ' +bar\n' + + "✓ expected 'foo' to be a string" + ); + }); + }); + + describe('and the second expression is a function', () => { + it('fails with a diff including all items in the chain', () => { + expect( + function() { + expect.it('to be a string').and(function(value) { + expect(value, 'to equal', 'bar'); + })('foo'); + }, + 'to throw', + "✓ expected 'foo' to be a string and\n" + + "⨯ expected 'foo' to equal 'bar'\n" + + '\n' + + ' -foo\n' + + ' +bar' + ); + }); + }); + }); }); }); From cc6c07da98684fe7cd7765f4217a99dd4745f543 Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Wed, 3 Oct 2018 08:20:27 +0200 Subject: [PATCH 29/34] Don't be retro --- test/api/it.spec.js | 10 +++++----- test/assertions/to-satisfy.spec.js | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/api/it.spec.js b/test/api/it.spec.js index db19293da..5a6813690 100644 --- a/test/api/it.spec.js +++ b/test/api/it.spec.js @@ -346,14 +346,14 @@ describe('expect.it', () => { describe('when passed a function', () => { it('should succeed', () => { - expect.it(function(value) { + expect.it(value => { expect(value, 'to equal', 'foo'); })('foo'); }); it('should fail with a diff', () => { expect( - function() { + () => { expect.it(function(value) { expect(value, 'to equal', 'bar'); })('foo'); @@ -378,7 +378,7 @@ describe('expect.it', () => { it('should fail when passed more than two arguments', () => { expect( - function() { + () => { expect.it(function(value) { expect(value, 'to equal', 'bar'); }, 'yadda')('foo'); @@ -392,7 +392,7 @@ describe('expect.it', () => { describe('and the first expression is a function', () => { it('fails with a diff including all items in the chain', () => { expect( - function() { + () => { expect .it(function(value) { expect(value, 'to equal', 'bar'); @@ -412,7 +412,7 @@ describe('expect.it', () => { describe('and the second expression is a function', () => { it('fails with a diff including all items in the chain', () => { expect( - function() { + () => { expect.it('to be a string').and(function(value) { expect(value, 'to equal', 'bar'); })('foo'); diff --git a/test/assertions/to-satisfy.spec.js b/test/assertions/to-satisfy.spec.js index 5200acaa6..47e75164e 100644 --- a/test/assertions/to-satisfy.spec.js +++ b/test/assertions/to-satisfy.spec.js @@ -689,7 +689,7 @@ describe('to satisfy assertion', () => { it('should fail with an diff if the function fails', () => { expect( - function() { + () => { expect({ foo: 3 }, 'to satisfy', { foo: expect.it(function(v) { expect(v, 'to equal', 2); @@ -2316,7 +2316,7 @@ describe('to satisfy assertion', () => { it('should not break when the assertion fails and there is a fulfilled function in the RHS', () => { expect( - function() { + () => { expect({}, 'to satisfy', { bar: 123, foo: expect.it(function(v) { @@ -2325,7 +2325,7 @@ describe('to satisfy assertion', () => { }); }, 'to throw', - function(err) { + err => { // Compensate for V8 5.1+ setting { foo: function () {} }.foo.name === 'foo' // http://v8project.blogspot.dk/2016/04/v8-release-51.html expect( From 1d885d15cab67b3b873cbabb38a59742dbbabded Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Sat, 27 Oct 2018 18:45:15 +0000 Subject: [PATCH 30/34] Update eslint to version 5.8.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 17bf2cb67..f3dd4b61a 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "babel-preset-es2015-without-strict": "^0.0.4", "coveralls": "^3.0.0", "es5-shim": "^4.5.9", - "eslint": "^4.17.0", + "eslint": "^5.8.0", "eslint-config-pretty-standard": "^1.2.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-mocha": "^5.2.0", From f084a2a4b536ea3a284b9edfd9ca35ff93524c7d Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Wed, 31 Oct 2018 23:15:21 +0000 Subject: [PATCH 31/34] Update unexpected-documentation-site-generator to version 5.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index faaf2ea9f..e11967e64 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "rollup-plugin-uglify": "^6.0.0", "rsvp": "^4.7.0", "serve": "*", - "unexpected-documentation-site-generator": "^4.6.1", + "unexpected-documentation-site-generator": "^5.0.0", "unexpected-magicpen": "^1.0.0", "unexpected-markdown": "^1.7.4" }, From 3fdd797348890b42bcac4abcae9e4f8a559bef23 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Sat, 10 Nov 2018 20:55:18 +0000 Subject: [PATCH 32/34] Update eslint to version 5.9.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fe1d9fbdf..c7e40f586 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "babel-preset-es2015-without-strict": "^0.0.4", "coveralls": "^3.0.0", "es5-shim": "^4.5.9", - "eslint": "^4.17.0", + "eslint": "^5.9.0", "eslint-config-pretty-standard": "^1.2.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-mocha": "^5.2.0", From 0b91c99d6c7eba33b6a21ffaa23dda5d88b990d2 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Sun, 9 Dec 2018 08:20:27 +0000 Subject: [PATCH 33/34] Update eslint to version 5.10.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e693af7c..388bb28fb 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "babel-preset-es2015-without-strict": "^0.0.4", "coveralls": "^3.0.0", "es5-shim": "^4.5.9", - "eslint": "^5.9.0", + "eslint": "^5.10.0", "eslint-config-pretty-standard": "^2.0.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-mocha": "^5.2.0", From 9d6581b1a2afa3857c453bffb7d35273f16a62d6 Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Wed, 26 Dec 2018 12:10:13 +0100 Subject: [PATCH 34/34] Stop testing jest on all Node versions --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cf5448a3a..1ff1abd62 100644 --- a/Makefile +++ b/Makefile @@ -86,7 +86,7 @@ travis-main: clean lint test test-jasmine test-jest coverage -