Closed rafaeelaudibert closed 4 years ago
Yeah the test framework we're using here is unnecessarily verbose in my opinion, but it's what comes with oclif so we stuck with it. I'll take a look at your tests shortly, thanks for the contribution.
Hi @rafaeelaudibert, I've had a bit of a play around with this PR and made the following changes:
seed
from the array of build scripts. Most of our demo stores define a list of "build scripts" in their .chec.json
(example: https://github.com/chec/commercejs-nextjs-demo-store/blob/master/.chec.json#L3), and returning early means the other build scripts don't run. Most noticeably, the webpack dev server doesn't boot up if you return early. It does if you remove "seed" from the scripts array and continue.I believe the build failures are unrelated
Hi again, I've removed the prompt to skip seeding. All we really need is the optional flag to skip it. The extra prompt was the cause of the failing tests, since prompts need to be mocked in the unit tests. Thanks again!
Hello @robbieaverill! Thanks for taking some time, and improving on the PR! Thank you also for the merge, hope it was helpful!
It is a pity the testing is not that great :(. Maybe we could try to test in another way, or are we really locked to oclif?
Closes #28
I am having problems with the tests, as I've never used
mocha
andsinon
before (I always usejest
). I don't understand why the new test on thedemo-store
command test would fail, neither understand why tests would fail in other commands (such as it is now), as they don't call the code I've written. How can I mock theinquirer.prompt
so that it correctly handles the login prompt or the seeding prompt?I've tested the code per se, bringing it to the beginning of the demo-store command, and it works as intended: