Normally we are able to login with self signed certificate from localhost pointing to different server.
But during cypress end to end testing, this is failing with the
(uncaught exception)NotSupportedError: The user agent does not support public key credentials
Is there a cypress setting to configure and suppress this error?
This is observed mainly in chrome, chromium and electron environment but passing for firefox browser.
cypress : 13.3.0,
mac os sonoma: v14.4.1
chrome : 124.x
Working reference in firefox
Is the implementation below to be changed:
export default (email, password) => {
if (!window.PasswordCredential) {
return Promise.resolve(false);
}
const cred = new PasswordCredential({
id: email,
password,
name: email,
});
return navigator.credentials.store(cred).then(() => {
return true;
});
};
As per the doc:
https://developer.mozilla.org/en-US/docs/Web/API/PasswordCredential/PasswordCredential
I am not 100% sure if its because of PasswordCredential or browser not supporting. How can we stub this in cypress environment for chrome and other unsupported browsers?
Firefox browser is working absolutely fine, where as chrome is not. I upgraded node version from 16 to 18 and the superagent library to the latest to see if that helps, but no luck so far.
If you have a secure site certificate, you should be able to map that site to localhost
for testing purposes.
Referring to How to test an HTTPS site locally, the format in the old style cypress.json
is
{
"baseUrl": "https://my-secure-site:3000",
"hosts": {
"my-secure-site": "127.0.0.1"
}
}
Note the baseUrl
uses https
protocol, and it's domain is mapped to 127.0.0.1
or localhost
. This should stop the browser adjusting back to http
protocol.
Since cypress.json
is the older format, I looked for hosts
option on the current documentation Configuration and could not find it.
However there is an example in the Cypress github repo here, and Gleb has a later blog using it here, so it is worth trying out.