Skip to content

Conversation

@astonm
Copy link
Contributor

@astonm astonm commented Nov 2, 2021

This PR adds a test suite for the cd command that I used to verify the correctness of #37. I pulled in jest as the test runner, but the same idea could be implemented easily with another option.

To run the tests, npm test.

As written, the codebase relies on a shared global namespace which happens naturally in the browser, but not-so-naturally when running tests from the command line, so I had to put in a hacky global.whatever = prelude to get things set up before the tests run. In order to get require to work, I added module.exports to the ends of the necessary files, and guarded those with a check so that when the same code runs in browser (with no module global) it won't complain.

Lemme know if you prefer a different set of hacks! I imagine without bringing in a build system, something like what's here is going to be one of the better options.

@astonm
Copy link
Contributor Author

astonm commented Nov 3, 2021

Just added some code to run the tests as part of the GitHub checks, but it's not enabled on this PR. I'll admit I have no clue how to make that happen... Happy to remove that commit if it's not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant