'DOM validation fails when running npm run test
The following HTML document passes the W3C Validation check but fails the DOM Validation test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>The World Wide Web Project</title>
</head>
<body>
<h1>World Wide Web</h1>
<p>
The WorldWideWeb (W3) is a wide-area
<a href="http://info.cern.ch/hypertext/WWW/WhatIs.html">hypermedia</a>
information retrieval initiative aiming to give universal access to a
large universe of documents.
</p>
<p>
Everything there is online about W3 is linked directly or indirectly to
this document, including an
<a href="http://info.cern.ch/hypertext/WWW/Summary.html"
>executive summary</a
>
of the project,
<a
href="http://info.cern.ch/hypertext/WWW/Administration/Mailing/Overview.html"
>Mailing lists</a
>
, <a href="http://info.cern.ch/hypertext/WWW/Policy.html">Policy</a> ,
November's
<a href="http://info.cern.ch/hypertext/WWW/News/9211.html">W3 news</a> ,
<a href="http://info.cern.ch/hypertext/WWW/FAQ/List.html"
>Frequently Asked Questions </a
>.
</p>
<dl>
<dt>
<a href="http://info.cern.ch/hypertext/DataSources/Top.html"
>What's out there?</a
>
</dt>
<dd>
Pointers to the world's online information,
<a
href="http://info.cern.ch/hypertext/DataSources/bySubject/Overview.html"
>subjects</a
>
,
<a href="http://info.cern.ch/hypertext/DataSources/WWW/Servers.html"
>W3 servers</a
>, etc.
</dd>
<dt><a href="http://info.cern.ch/hypertext/WWW/Help.html">Help</a></dt>
<dd>on the browser you are using</dd>
<dt>
<a href="http://info.cern.ch/hypertext/WWW/Status.html"
>Software Products</a
>
</dt>
<dd>
A list of W3 project components and their current state. (e.g.
<a href="http://info.cern.ch/hypertext/WWW/LineMode/Browser.html"
>Line Mode</a
>
,X11
<a href="http://info.cern.ch/hypertext/WWW/Status.html#35">Viola</a> ,
<a href="http://info.cern.ch/hypertext/WWW/NeXT/WorldWideWeb.html"
>NeXTStep</a
>
,
<a href="http://info.cern.ch/hypertext/WWW/Daemon/Overview.html"
>Servers</a
>
,
<a href="http://info.cern.ch/hypertext/WWW/Tools/Overview.html"
>Tools</a
>
,
<a href="http://info.cern.ch/hypertext/WWW/MailRobot/Overview.html"
>Mail robot</a
>
,
<a href="http://info.cern.ch/hypertext/WWW/Status.html#57">Library</a> )
</dd>
<dt>
<a href="http://info.cern.ch/hypertext/WWW/Technical.html">Technical</a>
</dt>
<dd>Details of protocols, formats, program internals etc</dd>
<dt>
<a href="http://info.cern.ch/hypertext/WWW/Bibliography.html"
>Bibliography</a
>
</dt>
<dd>Paper documentation on W3 and references.</dd>
<dt>
<a href="http://info.cern.ch/hypertext/WWW/People.html">People</a>
</dt>
<dd>A list of some people involved in the project.</dd>
<dt>
<a href="http://info.cern.ch/hypertext/WWW/History.html">History</a>
</dt>
<dd>A summary of the history of the project.</dd>
<dt>
<a href="http://info.cern.ch/hypertext/WWW/Helping.html"
>How can I help</a
>?
</dt>
<dd>If you would like to support the web..</dd>
<dt>
<a href="http://info.cern.ch/hypertext/README.html">Getting code</a>
</dt>
<dd>
Getting the code by
<a
href="http://info.cern.ch/hypertext/WWW/LineMode/Defaults/Distribution.html"
>anonymous FTP</a
>
, etc.
</dd>
</dl>
</body>
</html>
I get this error when I run npm run test
alok@alok-HP-ENVY-15-Notebook-PC:~/The-World-Wide-Web-Project/the-world-wide-web-project-master$ npm run test
> [email protected] test
> jest
FAIL __tests__/dom-validation.test.js
● Should check if there is a header and a paragraph element
expect(received).toBe(expected) // Object.is equality
Expected: 1
Received: 2
15 | expect(headerElements.length).toBe(1);
16 | const paraElements = document.getElementsByTagName('p');
> 17 | expect(paraElements.length).toBe(1);
| ^
18 | });
19 |
20 | test('Should find if there is an anchor element under paragraph tag', () => {
at Object.<anonymous> (__tests__/dom-validation.test.js:17:33)
PASS __tests__/w3c-html-validation.test.js
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 failed, 5 passed, 6 total
Snapshots: 0 total
Time: 2.929 s, estimated 7 s
Ran all test suites.
Could someone please point out where am I going wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
