r/javascript 6d ago

Browser Test: A browser-based automated javascript testing framework in one .html file

https://github.com/swans-one/browser-test

Hi r/javascript! I want to share a small javascript testing project I wrote.

When I write small javascript projects that use browser APIs (most recently working with IndexedDB) I often choose not to write tests because it's a pain to either mock those interfaces server-side, and it's also a pain to setup a browser automation tool.

To solve this, I wrote up a super concise testing framework (~140 lines of JS) inside a html file that can just be dropped into a project and act as a simple test framework.

This obviously doesn't work in all situations. A big drawback is that there's no reasonable way to connect it to a CI pipeline. However for small projects, and during development, I've found it really fun and fast to use.

I'm very interested to hear what you think, or if you have other ways you've approached this situation in the past.

14 Upvotes

8 comments sorted by

View all comments

3

u/evoactivity 6d ago

Did you come across testem? Been doing testing in real browsers for over a decade. You can start super simple and scale up to more complex setups.

https://github.com/testem/testem

1

u/allium-dev 6d ago

I haven't come across testem, thanks for sharing, I'm definitely going to check it out! I already like that it just runs a server on localhost that you can navigate to with your browser. It also looks like it has a mode to run under CI tools as well. Very neat.