Giter Club home page Giter Club logo

Comments (6)

snypelife avatar snypelife commented on May 4, 2024 1

While not explicitly testing related, having an area that explains how to implement dependency injection for things like lib functions and middleware I think would be useful as it would open a nice segue into better stubbing and writing more thorough tests.

from nodebestpractices.

davesnx avatar davesnx commented on May 4, 2024 1

I will try to get some time to write about testing pyramid, I'm not a native english speaker soooo It would take a little extra time. Thanks.

Instead of creating a topic about avoiding mocks, we could get deep into what kind of tests you can make, what are the patterns or anti-patterns that may appear into your test suit.

from nodebestpractices.

goldbergyoni avatar goldbergyoni commented on May 4, 2024

@davesnx thanks for the idea. Can you share some link/paste of a quote that nicely describes the downside of mocks + the *specific testing pyramid that you refer to?

from nodebestpractices.

davesnx avatar davesnx commented on May 4, 2024

Those are different topics around testing.

About mocking, I can't explain it in a short amount of time. But I think most of us we experienced before, that mocking a piece is just isolate from the real implementation. You can fall into the temptation to mock everything and you woudn't have a nice test.

https://medium.com/javascript-scene/mocking-is-a-code-smell-944a70c90a6a


The idea behind testing pyramid is to have a pyramid with 3 variables: time it takes to run/number of tests/responsability.

Looks something like that:

The pyramid is the distribution of the number of tests that your app should have or how to distribute it.

A lot of unit that tests the smallest logic and usually are fast.
Have a little less integration that tests the behaviour between components and logic
And even less e2e that tests contracts between services (maybe UI tests, depends on your App)
Finally just a few canaries, the ones that test directly production.

Just for the reference: https://martinfowler.com/bliki/TestPyramid.html

from nodebestpractices.

goldbergyoni avatar goldbergyoni commented on May 4, 2024

@davesnx the testing pyramid seems related to 4.1 as it deals with testing focus. Would you like to PR it?

About avoiding mocks - I'm not sure whether we should provide general testing advice that don't change the way you code Node.JS, or maybe it does?

@snypelife middleware testing is indeed a challenge to write about, Would you like to lead that? what are lib functions?

from nodebestpractices.

stale avatar stale commented on May 4, 2024

Hello there! 👋
This issue has gone silent. Eerily silent. ⏳
We currently close issues after 100 days of inactivity. It has been 90 days since the last update here.
If needed, you can keep it open by replying here.
Thanks for being a part of the Node.js Best Practices community! 💚

from nodebestpractices.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.