jestjssalesforcejsforce

Login to Salesforce using jsForce when running Jest test


I'm trying to login using the jsForce package while running a node test. No matter what I do, it fails out with the error message of...

Error: INVALID_LOGIN: Invalid username, password, security token; or user locked out.

I do not have this problem when spinning up my whole project. It logs in fine. I've double and triple check that the login url is set correctly and that the username and password are correct from my env file. I cannot find any answers on this.

Has anyone figured out how to actually login using jsForce while running a jest test?


Solution

  • FYI if you're trying to login with Jest, make sure your password does not contain a '$' character. Due to the way Jest cleanses env variables, it will remove that character. It took me ages to figure this out. Figure it might help someone save some time.