-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Fix diffing object contain readonly symbol key object #10414
Merged
SimenB
merged 15 commits into
jestjs:master
from
WeiAnAn:fix_diffing_object_contain_readonly_symbol_key_property
Aug 19, 2020
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8ae2068
refactor deepCyclicCopyObject
WeiAnAn 58af88e
add object contain readonly symbol key object test
WeiAnAn 95eb84c
update wrong test position
WeiAnAn b9fcdf6
update CHANGELOG
WeiAnAn 04e47ad
add a link to the typescript issue
WeiAnAn 930e198
sort changelog alphabetical
WeiAnAn b9436a1
shuold not skips non-enumerables property
WeiAnAn f8e4885
use node.cloneNode(true) to copy DOM node
WeiAnAn 8656b70
skip nonenumerable property when calling forEach
WeiAnAn c524e02
remove comment
WeiAnAn df80075
add domDiffing e2e test
WeiAnAn 48c5dca
replace output time
WeiAnAn b90b04f
add eslint-env and copyright header
WeiAnAn a4208a5
add deepCyclicCopyReplaceableDom test
WeiAnAn 6ccc83b
update snapshot
WeiAnAn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should work without error 1`] = ` | ||
"FAIL __tests__/dom.test.js | ||
✕ use toBe compare two div (<<REPLACED>>) | ||
✕ compare span and div (<<REPLACED>>) | ||
|
||
● use toBe compare two div | ||
|
||
expect(received).toBe(expected) // Object.is equality | ||
|
||
If it should pass with deep equality, replace \\"toBe\\" with \\"toStrictEqual\\" | ||
|
||
Expected: <div /> | ||
Received: serializes to the same string | ||
|
||
12 | const div1 = document.createElement('div'); | ||
13 | const div2 = document.createElement('div'); | ||
> 14 | expect(div1).toBe(div2); | ||
| ^ | ||
15 | }); | ||
16 | | ||
17 | test('compare span and div', () => { | ||
|
||
at Object.toBe (__tests__/dom.test.js:14:16) | ||
|
||
● compare span and div | ||
|
||
expect(received).toBe(expected) // Object.is equality | ||
|
||
- Expected - 1 | ||
+ Received + 1 | ||
|
||
- <span /> | ||
+ <div /> | ||
|
||
16 | | ||
17 | test('compare span and div', () => { | ||
> 18 | expect(document.createElement('div')).toBe(document.createElement('span')); | ||
| ^ | ||
19 | }); | ||
20 | | ||
|
||
at Object.toBe (__tests__/dom.test.js:18:41) | ||
|
||
Test Suites: 1 failed, 1 total | ||
Tests: 2 failed, 2 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites." | ||
`; |
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,16 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
import runJest from '../runJest'; | ||
import {replaceTime} from '../Utils'; | ||
|
||
test('should work without error', () => { | ||
const output = runJest('dom-diffing'); | ||
expect(output.failed).toBe(true); | ||
expect(replaceTime(output.stderr)).toMatchSnapshot(); | ||
}); |
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,19 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
/* eslint-env browser */ | ||
|
||
test('use toBe compare two div', () => { | ||
const div1 = document.createElement('div'); | ||
const div2 = document.createElement('div'); | ||
expect(div1).toBe(div2); | ||
}); | ||
|
||
test('compare span and div', () => { | ||
expect(document.createElement('div')).toBe(document.createElement('span')); | ||
}); |
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,3 @@ | ||
{ | ||
"jest": {} | ||
} |
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
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
29 changes: 29 additions & 0 deletions
29
packages/jest-matcher-utils/src/__tests__/deepCyclicCopyReplaceableDom.test.ts
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,29 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @jest-environment jsdom | ||
*/ | ||
/* eslint-env browser*/ | ||
import deepCyclicCopyReplaceable from '../deepCyclicCopyReplaceable'; | ||
|
||
test('should copy dom element', () => { | ||
const div = document.createElement('div'); | ||
const copied = deepCyclicCopyReplaceable(div); | ||
expect(copied).toEqual(div); | ||
expect(div === copied).toBe(false); //assert reference is not the same | ||
}); | ||
|
||
test('should copy complex element', () => { | ||
const div = document.createElement('div'); | ||
const span = document.createElement('span'); | ||
div.setAttribute('id', 'div'); | ||
div.innerText = 'this is div'; | ||
div.appendChild(span); | ||
const copied = deepCyclicCopyReplaceable(div); | ||
expect(copied).toEqual(div); | ||
expect(div === copied).toBe(false); //assert reference is not the same | ||
expect(div.children[0] === copied.children[0]).toBe(false); //assert reference is not the same | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe? not sure if it's better or not