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

Check for existence of Element when comparing DOM-nody-things (#7786) #7791

Closed
wants to merge 108 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
d8e57bf
Check for existence of `Element` when comparing DOM-nody-things (#7786)
mfeineis Feb 3, 2019
3b1f239
Fall back to deep equality for presumed DOM nodes if `Element` is not…
mfeineis Feb 4, 2019
3347089
Remove IE<9 specific fallback DOM node comparison (#7786)
mfeineis Feb 4, 2019
c49a4c9
Check for global DOM `Node` in `isDomNode` (#7786)
mfeineis Feb 5, 2019
b4d9b34
Check that `isEqualNode` is a function and remove duck typing from `i…
mfeineis Feb 6, 2019
0ac8fc6
Addressing malfunctioning code snippet. (#7789)
ExSidius Feb 3, 2019
08762b3
Exclude setup files from coverage (#7790)
lekterable Feb 4, 2019
fdb3acc
fix: make babel-jest warn when file to tarnsform is ignored by babel …
SimenB Feb 4, 2019
c3873a1
fix: ignore TS type references when looking for out-of-scope referenc…
SimenB Feb 4, 2019
34445fa
Release 24.1.0
rubennorte Feb 5, 2019
0fe62af
chore: new version of website
SimenB Feb 5, 2019
85b9ff3
Fix typo in question.md issue template (#7806)
hramos Feb 5, 2019
625ffec
Setup building, linting and testing of TypeScript (#7808)
SimenB Feb 6, 2019
9ab20f6
chore: downgrade yarn on windows on azure
SimenB Feb 6, 2019
830bc74
docs: link to json output example
OlivierJM Feb 6, 2019
935b295
Migrate pretty-format to TypeScript (#7809)
SimenB Feb 6, 2019
dbcfbb0
chore move @types/jest dep to the root of the project
SimenB Feb 6, 2019
9425c0d
Migrate diff-sequences to Typescript (#7820)
lorenzorapetti Feb 6, 2019
f37360d
Migrate jest-get-type to TypeScript (#7818)
SimenB Feb 6, 2019
6acbd01
Migrate jest-regex-util to Typescript (#7822)
lorenzorapetti Feb 6, 2019
a417f98
chore: migrate jest-diff to TypeScript (#7824)
SimenB Feb 7, 2019
1573eca
Migrate jest-leak-detector to TypeScript (#7825)
r3nya Feb 7, 2019
5c55994
chore: correct type errors in leak-detector unit test
SimenB Feb 7, 2019
59d9f28
chore: bump typescript eslint parser
SimenB Feb 7, 2019
3a90e47
Refactor -o & --coverage implementation | Fixes #6859 (#7611)
MarcoScabbiolo Feb 7, 2019
e37f1a9
Migrate jest-changed-files to Typescript (#7827)
lorenzorapetti Feb 7, 2019
1aa82f9
chore: Remove redundant stripAnsi from test (#7833)
vitkarpov Feb 8, 2019
ecc8518
chore: remove cyclic dev dep on jest-diff from pretty-format
SimenB Feb 8, 2019
7a7cad7
chore: migrate jest-matcher-util to TypeScript (#7835)
SimenB Feb 8, 2019
ce29b72
chore: migrate jest-docblock to TypeScript (#7836)
SimenB Feb 8, 2019
d05105a
chore: migrate jest-serializer to TypeScript (#7841)
thymikee Feb 9, 2019
413a15b
chore: migrate jest-message-util to TypeScript (#7834)
SimenB Feb 9, 2019
4a66dd0
chore: migrate jest-util to TypeScript (#7844)
SimenB Feb 10, 2019
8bbf394
chore: migrate jest-watcher to TypeScript (#7843)
SimenB Feb 10, 2019
ecf9952
chore: migrate jest-mock to TypeScript (#7847)
thymikee Feb 10, 2019
946d7fb
chore: followup to jest-mock TS migration (#7850)
thymikee Feb 10, 2019
12a297f
chore: migrate jest-worker to TypeScript (#7853)
SimenB Feb 10, 2019
fef7e70
chore: add missing reference to jest-message-util from jest-util
SimenB Feb 11, 2019
4fbac17
chore: inherit stdio when running tsc for better output
SimenB Feb 11, 2019
68bdc36
fix: Windows-specific test timeout issues introduced by Yarn 1.13.0 (…
willsmythe Feb 11, 2019
77c064d
chore: migrate jest-haste-map to TypeScript (#7854)
SimenB Feb 12, 2019
f326142
Use symbol instead of Symbol (#7869)
bokuweb Feb 12, 2019
dadb766
expect: Improve report when matcher fails, part 7 (#7866)
pedrottimark Feb 12, 2019
99af560
contributing guide section about changelog entries (#7877)
jeysal Feb 12, 2019
916a745
Fix image URLs (#7872)
georgeblahblah Feb 12, 2019
5aa17d2
chore: fix jest-mock spyOn argument inferring (#7878)
SimenB Feb 13, 2019
31b4c6a
Fix custom async matcher stack traces (#7652)
Feb 13, 2019
7dda866
chore: migrate babel-jest to TypeScript (#7862)
SimenB Feb 13, 2019
b65ccaa
chore: fix test for node 6
SimenB Feb 13, 2019
2bc4d44
chore: run typescript build as part of typecheck, not normal build (#…
SimenB Feb 13, 2019
a986f07
Improve hg revset used by jest-changed-files (#7880)
quark-zju Feb 13, 2019
feea117
chore: use more `private` (#7882)
SimenB Feb 13, 2019
b137ffb
expect: Improve report when matcher fails, part 8 (#7876)
pedrottimark Feb 13, 2019
3e2d228
chore: migrate jest-resolve to TypeScript (#7871)
SimenB Feb 13, 2019
f3d1bb0
Support React.memo in pretty-format (#7891)
bensampaio Feb 14, 2019
0dc842a
Typo fix in code comment (#7897)
DenrizSusam Feb 14, 2019
da14b66
fix: validating async functions (#7894) (#7896)
ehmicky Feb 14, 2019
38698cb
Inherit "only" mode unless there is tests with "only" mode already (#…
doniyor2109 Feb 14, 2019
05b1c6b
chore: fix import in build watch script
SimenB Feb 14, 2019
1080a59
chore: upgrade @types/jest (#7901)
SimenB Feb 14, 2019
3c48eef
Fixes Prototype Pollution vulnerability in Handlebars dependency (#7904)
tonycassara Feb 14, 2019
51d5a8a
chore: split out reporters into separate package (#7902)
SimenB Feb 15, 2019
8cc3bfd
Fix typo in config init (#7905)
pkuczynski Feb 15, 2019
b6834d4
jest snapshot - TS migration (#7899)
doniyor2109 Feb 16, 2019
0d697f8
feat: create new @jest/transform package (#7915)
SimenB Feb 16, 2019
31497ce
chore: Migrate babel-plugin-jest-hoist to Typescript (#7898)
deneuv34 Feb 16, 2019
8d6c6ce
create @jest/core package (#7696)
SimenB Feb 16, 2019
fb534d3
chore: collect coverage from TS files
SimenB Feb 17, 2019
f5e04f4
chore: migrate @jest/transform to TypeScript (#7918)
SimenB Feb 17, 2019
9cbafef
chore: upgrade flow
SimenB Feb 17, 2019
64980c8
Remove unnecessary config checks (#7801)
lekterable Feb 18, 2019
deedf4c
Align readme (#7927)
mjesun Feb 18, 2019
dd45b25
Add missing import to docs (#7928)
egdbear Feb 18, 2019
ab08116
Adds @babel/core to the peer dependencies (#7930)
arcanis Feb 18, 2019
6db372f
Fix queue management in jest-worker (#7934)
mjesun Feb 19, 2019
3e15abc
feat: print stack on preset normalize error (#7935)
wtho Feb 19, 2019
df29589
chore: migrate jest-resolve-dependencies to TypeScript (#7922)
jeysal Feb 19, 2019
ee1955e
Migrate expect to typescript (#7919)
Feb 20, 2019
9018f3c
`toStrictEqual` does not consider arrays with objects having undefine…
dubzzz Feb 20, 2019
82d25a5
chore: upgrade babel-core typings
SimenB Feb 21, 2019
11077a8
Fix transformer signature in babel-jest (#7945)
rubennorte Feb 21, 2019
aa03cb0
expect, jest-matcher-utils: Improve report when matcher fails, part 9…
pedrottimark Feb 22, 2019
713ddc0
chore: update failing snapshot
SimenB Feb 22, 2019
fcb73c4
fix jest-haste-map-types (#7951)
jeysal Feb 22, 2019
5aaf200
fix Node 6 build (#7955)
jeysal Feb 22, 2019
76bc0d0
chore: add missing npmignore to jest-circus
SimenB Feb 22, 2019
c5fd561
expect: Improve report when matcher fails, part 10 (#7960)
pedrottimark Feb 22, 2019
50f1ef3
fix(jest-changed-files): only return files from `getChangedFilesFromR…
jumoel Feb 22, 2019
ce545e3
TS migration `jest-circus` (#7916)
doniyor2109 Feb 22, 2019
261fc65
chore: simplify types in jest-changed-files
SimenB Feb 23, 2019
cd43f6e
Migrate jest-phabricator to TypeScript (#7965)
r3nya Feb 23, 2019
afa5729
chore: correct jest-phabricator export
SimenB Feb 23, 2019
3394b0d
chore: remove custom coverage typings (#7967)
SimenB Feb 23, 2019
9467a73
decentralize resolve types (#7966)
jeysal Feb 23, 2019
80523fd
decentralize jest-snapshot types (#7973)
jeysal Feb 24, 2019
8f7e6b4
decentralize jest-mock types (#7971)
jeysal Feb 24, 2019
ab838a6
decentralize pretty-format types (#7972)
jeysal Feb 24, 2019
7f07774
Migrate jest-runner to typescript (#7968)
Feb 25, 2019
8d38dce
chore: migrate jest-runtime to TypeScript (#7964)
SimenB Feb 25, 2019
038a993
Remove console.log from the front page (#7977)
sookcha Feb 25, 2019
6ed8875
chore: attempt to fix flaky test
SimenB Feb 25, 2019
410d5c9
(docs) Add missing numTodoTests in Result Object. (#7976)
dashmug Feb 25, 2019
12053a6
Fix asymmetric equal for Number (#7948)
dubzzz Feb 25, 2019
21a4547
chore: extract FakeTimers into a separate package (#7987)
SimenB Feb 26, 2019
4730c9d
chore: cleanup JestEnvironment types (#7988)
SimenB Feb 26, 2019
e5a7739
chore: migrate jest-config to TypeScript (#7944)
SimenB Feb 26, 2019
6dbd4df
Improve instructions for enabling typescript support (#7989)
tjallingt Feb 26, 2019
9cd7b90
Merge branch 'master' into expect-dom-nodeenv-bug-7786
mfeineis Feb 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1996,6 +1996,28 @@ Expected: <green>{\\"a\\": 99}</>
Received: <red>{\\"a\\": 99}</>"
`;

exports[`.toEqual() {pass: false} expect({"nodeName": "div", "nodeType": 1}).not.toEqual({"nodeName": "div", "nodeType": 1}) 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.toEqual(</><green>expected</><dim>)</>

Expected: <green>{\\"nodeName\\": \\"div\\", \\"nodeType\\": 1}</>
Received: <red>{\\"nodeName\\": \\"div\\", \\"nodeType\\": 1}</>"
`;

exports[`.toEqual() {pass: false} expect({"nodeName": "div", "nodeType": 1}).toEqual({"nodeName": "p", "nodeType": 1}) 1`] = `
"<dim>expect(</><red>received</><dim>).toEqual(</><green>expected</><dim>)</>

Difference:

<green>- Expected</>
<red>+ Received</>

<dim> Object {</>
<green>- \\"nodeName\\": \\"p\\",</>
<red>+ \\"nodeName\\": \\"div\\",</>
<dim> \\"nodeType\\": 1,</>
<dim> }</>"
`;

exports[`.toEqual() {pass: false} expect({"target": {"nodeType": 1, "value": "a"}}).toEqual({"target": {"nodeType": 1, "value": "b"}}) 1`] = `
"<dim>expect(</><red>received</><dim>).toEqual(</><green>expected</><dim>)</>

Expand Down
20 changes: 20 additions & 0 deletions packages/expect/src/__tests__/matchers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,16 @@ describe('.toEqual()', () => {
},
},
],
[
{
nodeName: 'div',
nodeType: 1,
},
{
nodeName: 'p',
nodeType: 1,
},
],
].forEach(([a, b]) => {
test(`{pass: false} expect(${stringify(a)}).toEqual(${stringify(
b,
Expand Down Expand Up @@ -537,6 +547,16 @@ describe('.toEqual()', () => {
},
},
],
[
{
nodeName: 'div',
nodeType: 1,
},
{
nodeName: 'div',
nodeType: 1,
},
],
].forEach(([a, b]) => {
test(`{pass: false} expect(${stringify(a)}).not.toEqual(${stringify(
b,
Expand Down
30 changes: 6 additions & 24 deletions packages/expect/src/jasmineUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,9 @@ function eq(

var aIsDomNode = isDomNode(a);
var bIsDomNode = isDomNode(b);
if (aIsDomNode && bIsDomNode) {
// At first try to use DOM3 method isEqualNode
if (a.isEqualNode) {
return a.isEqualNode(b);
}
// IE8 doesn't support isEqualNode, try to use outerHTML && innerText
var aIsElement = a instanceof Element;
var bIsElement = b instanceof Element;
if (aIsElement && bIsElement) {
return a.outerHTML == b.outerHTML;
}
if (aIsElement || bIsElement) {
return false;
}
return a.innerText == b.innerText && a.textContent == b.textContent;
}
if (aIsDomNode || bIsDomNode) {
return false;
// Use DOM3 method isEqualNode (IE>=9)
if (aIsDomNode && typeof a.isEqualNode === 'function' && bIsDomNode) {
return a.isEqualNode(b);
}

// Assume equality for cyclic structures. The algorithm for detecting cyclic
Expand Down Expand Up @@ -260,12 +245,9 @@ export function isA(typeName: string, value: unknown) {
}

function isDomNode(obj: any): obj is Node {
return (
obj !== null &&
typeof obj === 'object' &&
typeof obj.nodeType === 'number' &&
typeof obj.nodeName === 'string'
);
// In some test environments (e.g. "node") there is no `Node` even though
// we might be comparing things that look like DOM nodes.
return typeof Node !== 'undefined' && obj instanceof Node;
}

export function fnNameFor(func: Function) {
Expand Down