The Sauce Labs API

Hi, reading the Introduction to automated testing article, I tried running call_sauce.js but got this error:

let myAccount = new SauceLabs({
                ^

TypeError: SauceLabs is not a constructor

Can you please help me figuring out how to fix it?

Thanks,

Hello @Rafael_Green

not sure of the cause but can you check the folowing

  1. check if you installed the saucelabs api correctly try install it globally
  2. check the configration file if you used npm
  3. check the syntax for the account statement
  4. make sure to check the version of the saucelabs

could be other reason too but hope those help and have a nice day

I encountered this as well and pretty sure I followed the MDN instructions precisely.
I got past this error by changing the “require” first line to:
const SauceLabs = require('saucelabs').default;
But got other errors after this. Seems like this little sub-tutorial is out of date. Perhaps someone from Sauce Labs can propose fix.

1 Like

I found the solution on at the Node Sauce Labs repository: https://github.com/saucelabs/node-saucelabs. I created a pull request here: https://github.com/mdn/content/pull/30517#pullrequestreview-1748514218 with the changes needed for the Introduction to automated testing article: https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Automated_testing.

1 Like