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

dyowee
Why or when should one choose Tailwind over Bootstrap? :slight_smile:
New
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
The_Exile
I am new to programming. I started reading Eloquent Javascript 3rd Edition, as the book comes highly recommended as a good place for beg...
/js
New
brian
I’m working with a designer who created a design in Photoshop. I am mostly a Node.js and Android dev, but when I have worked with designe...
New
harwind
First have a look at the code: function mainfunc(func, par3, par2){ window[func](par3, par2); } function calledfunc(par3, par2){ ...
/js
New
JessicaW33
Hello All, How would you implement a navigation system in React Native? Could not find a way so I ask the community can someone help me ...
New
Fl4m3Ph03n1x
Background I have a button that may be disabled or not, depending on a set of conditions. I want to disable/enable the button without hav...
New
wilsoc31
First time building an app. It will run for Android and also for iPhone 15 but will not for iPod. Not sure why or where to even begin. ...
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
Rainer
Not sure if following fits exactly this thread, or if we should have a hobby thread… For many years I’m designing and building model air...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
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
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New
AstonJ
Curious what kind of results others are getting, I think actually prefer the 7B model to the 32B model, not only is it faster but the qua...
New