testdouble / teenytest

A very simple, zero-config test runner for Node.js
MIT License
96 stars 14 forks source link

Port the test:example tests to bats #46

Closed jasonkarns closed 5 years ago

jasonkarns commented 5 years ago

The smoke tests of the example project are a bit confusing as they're inlined in npm-scripts; especially as one test asserts an expected failure (which causes "not ok" to be printed to output)

This PR adds bats (unit test framework for bash) as a devDep and implements the two example tests in bats.

I suspect bats would make a superior tool for testing the teenytest CLI (and/or for SAFE tests). Doing so would allow a clean cognitive break between "JS of teenytest" and "JS of the test". Bats is also specifically built for testing command line utilities, so asserting on output and exit status after running commands is intuitive. However, this PR does not make any assumptions about the future use of bats within teenytest's test suite. So there is no directory of bats tests, nor does this test pull in any of the common bats assertion helpers or create a test_helper.bash. Those things will be desired if a larger bats test suite is built. For now, this PR limits bats use to only the two example tests that were in package.json; and the test file is placed in the safe directory. (But as it is a .bats file, isn't run by the safe suite; instead being run via bats safe or the corresponding npm run test:example script.)

/cc @agent-0028 @cpruitt