Skip to content

Commit

Permalink
WIP: getting close to a working version
Browse files Browse the repository at this point in the history
  • Loading branch information
Kent C. Dodds committed Mar 28, 2017
1 parent 60b4139 commit 6efe6f1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/jest-jasmine2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"main": "build/index.js",
"dependencies": {
"graceful-fs": "^4.1.11",
"jest-diff": "^19.0.0",
"jest-matcher-utils": "^19.0.0",
"jest-matchers": "^19.0.0",
"jest-message-util": "^19.0.0",
Expand Down
24 changes: 23 additions & 1 deletion packages/jest-jasmine2/src/jasmine/Spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* eslint-disable sort-keys */
'use strict';

const diff = require('jest-diff');
const {
matcherHint,
printReceived,
printExpected,
} = require('jest-matcher-utils');
const ExpectationFailed = require('../ExpectationFailed');
const expectationResultFactory = require('../expectationResultFactory');

Expand Down Expand Up @@ -121,10 +127,26 @@ Spec.prototype.onException = function onException(e) {
return;
}

const {expected, actual} = e || {};
let message;
if (expected && actual) {
const diffString = diff(expected, actual, {
expand: this.expand,
});
message = matcherHint('.toBe') +
'\n\n' +
`Expected value to be (using ===):\n` +
` ${printExpected(expected)}\n` +
`Received:\n` +
` ${printReceived(actual)}` +
(diffString ? `\n\nDifference:\n\n${diffString}` : '');
}

this.addExpectationResult(
false,
{
matcherName: '',
matcherName: 'blah',
message,
passed: false,
expected: '',
actual: '',
Expand Down

0 comments on commit 6efe6f1

Please sign in to comment.