Closed AtkinsSJ closed 4 months ago
I'm very unfamiliar with Mocha so I'm probably doing something wrong. In particular, it'd be nice if all the builtins were grouped together, but I couldn't see a way to do that without putting all the tests in the same file, which is awkward.
I'm very unfamiliar with Mocha so I'm probably doing something wrong. In particular, it'd be nice if all the builtins were grouped together, but I couldn't see a way to do that without putting all the tests in the same file, which is awkward.
I wasn't sure myself but after a quick test it looks like this approach works:
Thanks! I couldn't directly use require()
because we use JS modules, but I've done the equivalent with imports and calling the functions, and that works:
This is a first attempt at making our builtins testable. It provides a mock context that lets us pass in parameters and options directly (without running parsing code) and check that the return value, and stdout/stderr outputs are as they should be.
Includes tests for
true
,false
,basename
andecho
, since those do not touch the filesystem. Theecho
test is missing coverage for the-e
and-E
options because as far as I can tell, ourecho
doesn't perform the interpretation properly, but just skips over the escape sequence, regardless of which options are provided.