cypress-social-logins: Error: module not found: "ws" from file ..... node_modules/puppeteer/lib/WebSocketTransport.js
-
Library Version:

-
OS: MacOS v 10.14.6
-
Node.js Version: v10.15.0
What causes this error?
-
after installing the plugin, using the following: ‘yarn add cypress-social-logins’
-
and invoking the cypress test runner: ‘CYPRESS_BASE_URL=“https://accounts.google.com” yarn cypress’
-
I’m getting the following error; Error: module not found: “ws” from file … /node_modules/puppeteer/lib/WebSocketTransport.js
-
example code is:
module.exports = (on, config) => {
on('task', {
GoogleSocialLogin: GoogleSocialLogin
})
}
describe('Login', () => {
it('Login through Google', () => {
const username = ('XYZ1234');
const password = ('XYZ1234');
const loginUrl = ('https://google.accounts.com/ServiceLogin')
const cookieName = ('cookieName')
const socialLoginOptions = {
username,
password,
loginUrl,
headless: false,
logs: true,
loginSelector: 'a[href="/auth/auth0/google-oauth2"]',
postLoginSelector: '.account-panel'
}
return cy.task('GoogleSocialLogin', socialLoginOptions).then(({cookies}) => {
cy.clearCookies()
const cookie = cookies.filter(cookie => cookie.name === cookieName).pop()
if (cookie) {
cy.setCookie(cookie.name, cookie.value, {
domain: cookie.domain,
expiry: cookie.expires,
httpOnly: cookie.httpOnly,
path: cookie.path,
secure: cookie.secure
})
Cypress.Cookies.defaults({
whitelist: cookieName
})
}
})
})
})
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (13 by maintainers)
No worries. This is what we have on the Troubleshooting section already so I hope it will be helpful for others in the future:
@lirantal problem in chair , not in computer.
I have been spending all week in the /support/index.js and I blindly added it there over the /plugins/index.js
Apologies for my stupidity on this one. I need more coffee
I also ran into this issue.
The problem was I was requiring
GoogleSocialLoginin my spec file in addition to requiring it incypress/plugins/index.js.Removing it from my spec file resolved the issue.
Sure. so it should be something as follows:
cypress/plugins/index.jsshould look as:cypress.jsonalong the lines of:And finally using it in a test is something along the lines of: