Comments (6)
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.
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.
@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.
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.
@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.
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)
- Easy to translate advice HOT 1
- Translations status HOT 1
- Bonnes pratiques nodejs
- Arabic Translation
- Node practice 1
- Should include Corepack in our recommendation? HOT 5
- Bootstraping nodejs container may be misleading
- Node
- Node js fullstack HOT 4
- Wrong example HOT 2
- Broken link to env-var
- Nextjs as main framework? HOT 2
- Another comment regarding "1.1 Structure your solutions by business components" HOT 1
- Italian Translation
- The backend-testing-checklist.png file is missing. HOT 3
- Hinglish Translation HOT 1
- Кнас
- Dead link for safe-regex
- Mi006
- Is using cache for npm install in docker safe?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodebestpractices.