synpress icon indicating copy to clipboard operation
synpress copied to clipboard

Confusing / wrong errors thrown when trying to run tests locally.

Open archae0pteryx opened this issue 3 years ago • 2 comments

The docs describe only needing a private key or seed phrase. The error when trying to run also says you need either or... however the code checks for the existence of 4 env vars.

if (
  !process.env.SECRET_WORDS &&
  !process.env.PRIVATE_KEY &&
  !process.env.SKIP_METAMASK_SETUP &&
  !process.env.SKIP_METAMASK_INSTALL
) {
  throw new Error(
    'Please provide SECRET_WORDS or PRIVATE_KEY environment variable',
  );
}

I wonder if you've considered using a library like dotenv or at least giving an example for folks. I think the minimum might be to throw a more complete error?

archae0pteryx avatar May 30 '22 20:05 archae0pteryx

Hello, I am currently working on a fix here.

I had a few questions, how do you plan to use this? Would an environment file be preferred?

kennetheversole avatar Jun 29 '22 02:06 kennetheversole

Hey @archae0pteryx, thanks for reporting.

This is what I have done:

// if user skips metamask install or setup
if (!process.env.SKIP_METAMASK_INSTALL && !process.env.SKIP_METAMASK_SETUP) {
  // we don't want to check for presence of SECRET_WORDS or PRIVATE_KEY
  if (!process.env.SECRET_WORDS && !process.env.PRIVATE_KEY) {
    throw new Error(
      'Please provide SECRET_WORDS or PRIVATE_KEY environment variable',
    );
  }
} else {
  log(
    'Skipping check for SECRET_WORDS and PRIVATE_KEY as SKIP_METAMASK_INSTALL or SKIP_METAMASK_SETUP is set',
  );
}

I hope this makes it clearer.

Please, let me know if you would like me to improve it further. Looking forward for suggestions!

Thanks, Jakub.

drptbl avatar Oct 31 '22 12:10 drptbl