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
TypeError: remoteJQuery is not a function #1502
Comments
I am unable to reproduce this issue with what you have provided. My working example: it('example', () => {
cy.visit('https://example.cypress.io/commands/actions')
cy.get('.action-email')
.then(elem => {
elem;
})
}) It looks as if you are targeting a |
I think I have some weird errors specific to my computer. I'm having no issues running the same tests on other computers. I may have to open a new issue and close this, but the most troubling problem of late is I cannot run more than one test, as it fails like this on the second test in a suite: My beforeEach looks like: beforeEach(() => {
cy.authenticatedVisit(url)
}) and the above command is defined in Cypress.Commands.add('authenticatedVisit', url => {
cy.visit(url, {
onBeforeLoad() {
window.localStorage.setItem('authRefreshToken', authRefreshToken)
window.localStorage.setItem('authAccessToken', null) //it needs this field to have an entry
},
})
})
|
Actually, I have this issue when my site has a kind of fake jQuery 💃 |
This is resolved with one of the recent updates to Cypress. I can't say which version/why it's fixed, but glad that it is the case. 🎉 |
I'm also experiencing this issue (v3.4.0 and v3.4.1). The app -- a very old legacy app -- under test isn't using JQuery but it does define an object It seems to stem from here
I'm not sure what I should I do here. Hopefully there's a configuration I can change? |
@marioparris-qless did you manage to solve it? I'm having the same issue. The webpage does not use jQuery, doing a console.log of window('jQuery') and window('$') shows undefined. Although I've looked in every dependency JS file from the page and have not found it being set anywhere. Here is the debugging I've done, in case it helps somebody to see the issue: Here we can see that state('window').$ is {}, but when printed before, it showed undefined. EDIT: cy.on('window:before:load', (win) => {
if (win.jQuery === undefined && (win.$ === undefined || win.$ === {})) {
Object.defineProperty(win, '$', {
configurable: false,
get: () => Cypress.cy.$$,
set: () => {}
});
}
}); |
@XPuigA No, I haven't been able to. You've gotten way further than I have! Edit: I've been able to work around it by not defining |
@marioparris-qless I think I fixed it with the following code: cy.on('window:before:load', (win) => {
if (win.jQuery === undefined && (win.$ === undefined || win.$ === {})) {
win.$ = Cypress.cy.$$;
}
}); For anyone else having the same problem, what the code does is, before loading every page in the spec, check if the Window object has the jQuery or $ properties, and if not, assign the jQuery that comes with Cypress to Window.$. |
I am experiencing the same issue with a site that uses jQuery and jQuery.noConflict() https://api.jquery.com/jQuery.noConflict/ |
Nice! |
We were in the similar situation, where our website made use of window.$ as something than jQuery. To give you a surprise, this is what we have: window.$ = document.querySelector.bind(document) It really made us worried initially that we would have to change all the occurrences of Cypress.on("window:before:load", () => {
/**
* Thankfully, Cypress searches for "jQuery" property on the state
* variable (cy), if that's present, it takes the precedence
* over window.$
* https://github.com/cypress-io/cypress/blob/7.0-release/packages/driver/src/cy/jquery.js#L12
*/
Cypress.cy.state("jQuery", Cypress.$);
}); We hope that this could help others too :) |
With Cypress I wonder if this issue is no longer there, since Cypress |
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
This issue has been closed due to inactivity. |
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
Current behavior:
cy.get(selector)
works fine.cy.get(selector).then((elem) => {})
with any callback results inTypeError: remoteJQuery
, with no extra informationDesired behavior:
cy.get(selector).then((elem) => {}) should give me access to the element.
Test code:
I've tried cy v2.0.4 and v2.1
on Mac OS 10.13.3 using chrome.
The text was updated successfully, but these errors were encountered: