-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support AssertionError expected and actual values (#3217)
* node `assert` snapshot tests * WIP: getting close to a working version * Refactor assert error messages * Remove jest-diff from jest-jasmine2 deps * Support throws and doesNotThrow assert matchers * Update snapshots * Fix snapshots across different node verions * Human readable messages
- Loading branch information
Showing
6 changed files
with
497 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
integration_tests/failures/__tests__/node-assertion-error-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @emails oncall+jsinfra | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
|
||
test('assert', () => { | ||
assert(false); | ||
}); | ||
|
||
test('assert with a message', () => { | ||
assert(false, 'this is a message'); | ||
}); | ||
|
||
test('assert.ok', () => { | ||
assert.ok(false); | ||
}); | ||
|
||
test('assert.ok with a message', () => { | ||
assert.ok(false, 'this is a message'); | ||
}); | ||
|
||
test('assert.equal', () => { | ||
assert.equal(1, 2); | ||
}); | ||
|
||
test('assert.notEqual', () => { | ||
assert.notEqual(1, 1); | ||
}); | ||
|
||
test('assert.deepEqual', () => { | ||
assert.deepEqual({a: {b: {c: 5}}}, {a: {b: {c: 6}}}); | ||
}); | ||
|
||
test('assert.deepEqual with a message', () => { | ||
assert.deepEqual({a: {b: {c: 5}}}, {a: {b: {c: 7}}}, 'this is a message'); | ||
}); | ||
|
||
test('assert.notDeepEqual', () => { | ||
assert.notDeepEqual({a: 1}, {a: 1}); | ||
}); | ||
|
||
test('assert.strictEqual', () => { | ||
assert.strictEqual(1, NaN); | ||
}); | ||
|
||
test('assert.notStrictEqual', () => { | ||
assert.notStrictEqual(1, 1, 'My custom error message'); | ||
}); | ||
|
||
test('assert.deepStrictEqual', () => { | ||
assert.deepStrictEqual({a: 1}, {a: 2}); | ||
}); | ||
|
||
test('assert.notDeepStrictEqual', () => { | ||
assert.notDeepStrictEqual({a: 1}, {a: 1}); | ||
}); | ||
|
||
test('assert.ifError', () => { | ||
assert.ifError(1); | ||
}); | ||
|
||
test('assert.doesNotThrow', () => { | ||
assert.doesNotThrow(() => { | ||
throw Error('err!'); | ||
}); | ||
}); | ||
|
||
test('assert.throws', () => { | ||
assert.throws(() => {}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.