Issue Link: cypress-io/cypress#6193
The following repository is a reduced test case for a bug in the Cypress testing tool. If a webpage with zero JavaScript present contains a DOM element with the id
attribute set to jquery
(for example, <p id="jquery">jQuery</p>
), then the error TypeError: item.first is not a function
is thrown.
(dist/index.html
)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Reduced Test Case</title>
</head>
<body>
<h1>Homepage</h1>
<p id="jquery">jQuery</p>
</body>
</html>
(cypress/e2e/homepage.js
)
describe("homepage", () => {
beforeEach(() => {
cy.visit("/");
});
it("should find the jQuery text", () => {
cy.findByText("jQuery").should("exist");
});
});
To reproduce the bug:
- Download this repository.
- Run
npm install && npm run test:e2e
. - Execute the test file
homepage.js
in Cypress Test Runner.
Close out the test runner via ctrl
+ c
. Remove the id
attribute from the element <p id="jquery">jQuery</p>
from dist/index.html
. Re-run npm run test:e2e
and re-execute the same test file as before.