davearonson

davearonson

Test coverage of plain JS, preferably w/o npm?

I’m unit-testing some JS, with Jasmine, and I’d like to check our coverage. We’re not using any front-end framework, nor much JS, so no other need to install npm, nor much additional other JS infrastructure, so we’d prefer not to. I’ve been trying to find lightweight options, and not coming up with anything, other than very clumsy dev-tools built into different browsers (and we haven’t standardized on one, and have customers that use different ones). Any ideas, if not of specific tools then at least where to look?

Most of the rest of the project is in Ruby, so gems are an option, but it’s not Rails and we definitely don’t want to drag that in as well. (It’s in Sinatra, but we may be moving away from that too, to just plain Rack. I doubt we’d go any lower-level than that though!) The only possibly-suitable thing I’ve found there is jscover, which hasn’t been updated in forever and depends strictly on such an outdated version of v8 that it’s a PITA to install it (in fact I tried for about four hours yesterday with all kinds of workarounds and failed).

Other details: I’m on a Mac, but we need it to work on Linux for most of the rest of the team. Windows not needed. NONE of us are JS wizards, I’ve got a decent handle on the language basics and some basic DOM manipulation but that’s about it, and still seem to be in the lead. We can certainly cobble pieces together with Ruby, bash scripting, maybe a few other languages, and baling wire.

Most Liked

iPaul

iPaul

In the JavaScript ecosystem using node (or npm) is like using gems in Ruby, you need to embrace it if you want to be able to do anything significant. You can get by with a minimal npm knowledge. That being said, node and npm works the same on macOS and Linux so your dev environment will be reproducible on Linux too (or you can use Docker). I recommend Jest Getting Started · Jest.

davearonson

davearonson

Makes sense, but I’m not sure if I want to do anything “significant” in JavaScript. I am not up-to-date on it, haven’t done all that much in a very long time, am not at all a front-ender (not that that’s bad, just different), and just don’t like JavaScript, at least insofar as I know it. On the other hand, it’s pretty much a necessary evil. On the gripping hand, I’m in the process of retiring, ideally having very little to do with JS ever again. :slight_smile: But in the meantime, my current client has some JS in need of testing, some I wrote, meaning I could put up with not-as-great tooling, but also some one of his employees wrote, and will probably continue to write, so I should set up something they can use decently well. Maybe coverage testing just won’t be part of that – or maybe we’ll get deep enough into JS and its tooling that we’ll bite the bullet and use npm. With judicious package management, maybe we can avoid having to upgrade our disks to hold the packages. :wink:

Where Next?

Popular Frontend topics Top

davearonson
I’m unit-testing some JS, with Jasmine, and I’d like to check our coverage. We’re not using any front-end framework, nor much JS, so no ...
New
New
Sally_san
So I’ve got a client that wants to build a site like this: Specifically 3 things from the website: The fullscreen sections that chang...
New
pillaiindu
I mean, when you render all the HTML at the server side and the data is sent through HTTP requests, except only if some tiny things are d...
New
beberardinelli
Hi! I just started coding a few months ago and I am trying to get all the help I can get. My friend showed me this debugging tool called...
New
sona11
I have a 1D array of numbers and need help splitting them into groups using a jagged array so that I can perform a series of computations...
New
tomcatttttt
I’m trying to take the API from the site to get a seamless online game through the HTML5 API. It works in all browsers except Google Chro...
New
Fl4m3Ph03n1x
Background I have a a fresh umbrella project with a Phoenix app inside. To create the app I used the following commands: mix new test_a...
New
Fl4m3Ph03n1x
Background I have a custom component in my LiveView, which is basically a group of checkboxes. I want to add a new attribute to my custo...
New
Fl4m3Ph03n1x
Background I have Phoenix umbrella application. When inside said application, I can run it without issues if MIX_ENV=prod. However, if I ...
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
axelson
I’ve been really enjoying obsidian.md: It is very snappy (even though it is based on Electron). I love that it is all local by defaul...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New