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

reimplement unit tests #156

Merged
merged 2 commits into from
Feb 17, 2024
Merged

reimplement unit tests #156

merged 2 commits into from
Feb 17, 2024

Conversation

cloverich
Copy link
Owner

@cloverich cloverich commented Feb 17, 2024

  • re-work the unit testing from ts-node + esm + mocha, which was maybe never working, to esbuild + mocha
  • re-implement several of the SearchParser (formerly TagSearchStore) tests
  • a little bit of clean-up and documentation
  • remove esm and ts-node (were only used for tests)
  • add tests to ci (bonus!)

closes #117

I tried to get ts-node + esm working for quite a bit. I'm actually unsure if it was ever working, esp. given the comment (deleted below) alluding to the markdown tests never running. I went the esbuild route in frustration, because I was pretty sure I could at least get it to work. While there's only a couple test files, its still shockingly fast ~1s to build each test bundle and run them, including the initial command invocation. The main draw back currently is there's no clear distinction between node and browser; anything even pulling in the window object may fail. But basic unit tests work, and being able to write them again is refreshing.

Also, node has its own testing library (import { test } from 'node:test'). It seems to require being run in esm mode. I briefly toyed with moving more of the project to ESM, but hit a few snags and maybe its a bigger change, will track in a follow up and include notes there. Ultimately getting to node testing is exciting, because I don't use many features from mocha / chai, and it will be even fewer dependencies to maintain without sacrificing any functionality.

- re-work the unit testing from ts-node + esm + mocha, which was maybe never working, to esbuild + mocha
- re-implement several of the SearchParser (formerly TagSearchStore) tests
- a little bit of clean-up and documentation
- remove esm and ts-node (were only used for tests)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.mjs because I wrote the imports before realizing this was js, then it ran without issue; eventually moving to esm anyways, so might as well.

const res = path.resolve(dir, dirent.name);
if (dirent.isDirectory()) {
findTestFiles(res, files);
} else if (dirent.name.endsWith(".test.ts")) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh the esbuild name uses .test.bundle.ts and if it turned into bundle.test.ts this might be confusing to debug.

@cloverich cloverich merged commit cd2ab19 into master Feb 17, 2024
2 checks passed
@cloverich cloverich deleted the testing branch February 17, 2024 04:16
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.

Better test support
1 participant