r/javascript • • Dec 04 '18

Modern JavaScript Explained For Dinosaurs

https://medium.com/the-node-js-collection/modern-javascript-explained-for-dinosaurs-f695e9747b70
452 Upvotes

72 comments sorted by

View all comments

10

u/haschdl Dec 04 '18

This was a very good summary, and an easy read, well done! But I still think JS development is a clumsy beast. One aspect I didn’t see covered: unit testing.

I was working on a side project, a library, and was very proud of not having to use Babel , because my library would only work in modern browsers anyway, so I was happy to use only ES6 features. I had to take a step back when incorporating unit tests with mocha and Nyc - mocha does not work with ES6 modules, so I had to use a library to transpile my code to an “older” way of doing things, so that I can unit test the code that is written in the modern way. I mean, this is not what a mature development workflow looks like.

14

u/fucking_passwords Dec 04 '18

JS does not really impose any particular development workflow, if you are not satisfied with your workflow you should probably change it. I get the spirit of what you’re saying, but I disagree that it’s an issue of maturity, JS has a pretty unique set of criteria that have led to the situation we find ourselves in

9

u/benihana react, node Dec 05 '18

so you tried mocha, an ancient testing framework and it didn't work out so you concluded javascript isn't mature? did you try any other libraries?

there are a ton of problems with javascript's development, but this is pretty much on you.

3

u/haschdl Dec 05 '18

Lol Fair enough. but that’s the point, ancient in JavaScript is what, 5 years?

5

u/StillChillin Dec 05 '18

"It's so difficult to sink this screw with my hammer, hammers suck!"

2

u/haschdl Dec 05 '18

😂 point taken

5

u/macaronisoft Dec 05 '18

Mocha was great. It was how I can learned unit testing in JavaScript. But I have to say jest is a joy to use. And it works well with es6. No transpilation needed. I've written thousands of lines of es6 code in the last few months and it's all unit tested with almost 100% coverage. Jest makes it pretty easy. Can't speak for other test libraries but I can say mocha has aged poorly :/

1

u/haschdl Dec 05 '18

I have to admit I could’ve have done more research on the test library. I will check jest!

4

u/I_LICK_ROBOTS Dec 05 '18

mocha does not work with ES6 modules, so I had to use a library to transpile my code to an “older” way of doing things

Sounds like mocha's not the right tool for your project at this point in time. Look at jasmine and karma (which is what angular uses) or any one of the hundreds of other unit testing frameworks written for JS.

One library not meeting your use case isn't indicative of an issue with JS as a whole. It means you picked the wrong tool, try a different one. If the tool you need doesn't exist yet take a stab at writing your own, or forking mocha. Even if your code isn't the best your ideas might inspire someone else. At the very least submit an issue (or +1) on github.

JS is growing, which means that you can shape the tools, libraries and community. All you need to do is participate.

The fact that some lib doesn't fit your use case (yet) isn't a problem with JS. It just means you (me and everyone else) have some work to do.

1

u/HarmonicAscendant Dec 05 '18

Mocha does work with ES6 modules if you install https://github.com/standard-things/esm and use:

mocha --require esm

1

u/haschdl Dec 05 '18

Thanks, I appreciate the feedback!

2

u/madworld Dec 04 '18

It scratches the surface on a lot of areas, but it would be fairly easy to overwhelm the intended audience. There is a lot to understand there without getting into linting, state management, testing, frameworks, etc.