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:

Popular Frontend topics Top

malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
wolf4earth
I’m currently in the process of rebuilding my personal website/blog from scratch. At the moment my website is using hugo, and while I thi...
New
AstonJ
DHH might like you to believe they are a thing of the past: https://twitter.com/dhh/status/1275902566719610880 I actually went down thi...
New
AstonJ
Wondering if anyone has any thoughts on choosing between these two languages for WebAssembly? I definitely want to explore wasm, and rea...
New
First poster: bot
Local PDF uses Webassembly to edit your PDFs inside your Browser. Your files won’t leave your System, they will not be sent to another se...
New
First poster: bot
Fable 3.1.16 has been released. Link: Release 3.1.16 · fable-compiler/Fable · GitHub
New
Ayushk
Hello, This is pretty basic. I was trying to explore the front-end development as I was not from a tech background. But, very much inter...
New
New
JesseSkinner
I’ve developed a video course called The Joy of Svelte, where I go in depth on Svelte features, especially different ways to manage state...
New
KnowledgeIsPower
These projects are new (not as maturing as Next/other SSG) but they look cool. Anyone using it and share their experience?
New

Other popular topics Top

siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1126 25226 746
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
PragmaticBookshelf
Author Spotlight Erin Dees @undees Welcome to our new author spotlight! We had the pleasure of chatting with Erin Dees, co-author of ...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New