To be useful and trustworthy, your CLIs should be extraordinarily reliable. Investing in testing early will reap rewards in future. We show how to set up basic tests with Jest and Oclif's test helpers.
where is the expect
commands come from ?
where is the
expect
commands come from?
The expect
command is apart of jest and is used to run tests. expect
is used to tell the computer what the output should be.
Thanks for this valuable lesson, Shawn. I have a couple of questions:
/n
at the end or expect(ctx.stdout.trim()).toBe('whatever')
?Thanks!
thanks for the lesson. I tried running tests using yarn jest
but I'm getting command <name> not found
error. Does anyone know how to fix this?
thanks for the lesson. I tried running tests using
yarn jest
but I'm gettingcommand <name> not found
error. Does anyone know how to fix this? You need to putjest
as as a script in package.json like below:
{
"scripts": {
"jest": "jest"
}
}