Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a simple test suite for cd commands #51

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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