Live data from Hacker News

Ask HN: Can you suggest some good JavaScript projects to read and learn?

news.ycombinator.com

41–49 of 49 posts

Re: Ask HN: Can you suggest some good JavaScript projects to read and learn?

#41
post #38

I'm also interested to see a mid-size scale SPA project that has excellent unit-testing and integration-testing. I've read a lot about how JS can make programmer productive, I've also read a lot how code can be succinct and all that jazz because of JS, but I have _never seen_ a well-architected, well-documented, well-automated-tested non-todomvc SPA codebase. This isn't a sarcasm or criticism but a serious and legiti…

I tried doing unit testing on our SPA codebase (200 k lines JS) for a while, but found it to not be worth the effort. UI is better tested through integration tests. We use selenium instead of jasmine these days. We have a ton of unit tests in the server code though, because it makes more sense there.

I think the right approach is to build from the ground up for testability both on unit-test and integration-test.

But one has to be very careful how to structure the pieces/components.

For example:

Do not write extensive unit-test on the UI but definitely have extensive Selenium tests for the UI _library_ (if you are a library builder). If you are a library user, assume the UI works as advertised and attaching/removing event-listener can be considered "configuration" type of code: test it once to see if it is configured properly and that's it!

If the SPA uses some sort of MVC/MVP, I'm hoping I can:

1. For unit-test

- unit-test individual M,V,C,P, Service, Helper, Model Validators, etc

- ability to mock different aspects

2. For integration-test

- ability to construct the whole thing (MVC/P) including the back-end, mock the View, and start controlling/simulating the code execution from the Controller/Presenter

The integration test can cover more than the unit-test to the point almost close to Selenium type of test but not as brittle as Selenium.

Re: Ask HN: Can you suggest some good JavaScript projects to read and learn?

#46

Earlier quoted context omitted.

Can you briefly expand the e2e test aspect of Angular? I'm looking to learn ways to do e2e test without touching the DOM (e.g.: from Controller all the way up to the back-end; imagine firing up Chrome DevTools console and start writing JS code that executes some logic and eventually fires AJAX request and process the response, of course in this case the View will be mocked but the app logic and everything else can be…

Checkout Angular's guide on e2e testing using https://docs.angularjs.org/guide/e2e-testing Also read about Protractor, http://angular.github.io/protractor/#/ , their e2e testing framework. These tests generally should be run in the browser. You can run them in PhantomJS, a command line browser simulator, but it's not the same and there are sometimes issues that don't get caught by Phantom. Best to run those tests in…

I went over those pages briefly and I wish it's not Selenium-like but it kinda is... :(

Re: Ask HN: Can you suggest some good JavaScript projects to read and learn?

#48

Earlier quoted context omitted.

We have a mid-size scale SPA and its suffering because of bloat. Functions are 2-500 lines long as an example. we've had critical bugs in the last 2 weeks and I got fed up and decided to start learning unit testing. Its been absolutely painful to get everything setup and started (Visual Studio). Nothing works. I would love to see a well written project to base my tests off of. I would really love to see a well writte…

That's not quite correct. I've had good success in architecting/designing classical web-app (MVC-ish as overall architecture and minimum JS on front-end). I can write unit-test with mocking and integration-test with in-memory database as part of my build/compile loop. But I struggled a lot with front-end.

Ah yeah, we're having lots of issues with front end bugs causing crashes.

Re: Ask HN: Can you suggest some good JavaScript projects to read and learn?

#49

Earlier quoted context omitted.

That's not quite correct. I've had good success in architecting/designing classical web-app (MVC-ish as overall architecture and minimum JS on front-end). I can write unit-test with mocking and integration-test with in-memory database as part of my build/compile loop. But I struggled a lot with front-end.

Ah yeah, we're having lots of issues with front end bugs causing crashes.

Front-end bugs causing crashes of... the back-end? That's a back-end bug.
Post reply on HN