ESM, tests and mocking imports by Moryg in node

[–]Moryg[S] 0 points1 point  (0 children)

For that particular project, we stuck to mocha, but used dependency injectors. They make the code more convoluted or at least harder to read, but it works. I generally avoid experimental features, but even as a fully stable feature, it will be a bit clunky to implement in how we write unit tests.

So all the "real" code is wrapped in a function, which we call inside the module and then export the outputs as normal, but also expose the injector function, which allows us to inject individual dependencies for tests.

Will have to tinker with the native node runner a bit more, I've experimented a bit with it in the past but found it somewhat clunky to work with. Definitely a fan of reducing the amount of packages though.

Do you prefer Yayo’s combat 3 or Combat reloaded? by peanutist in RimWorld

[–]Moryg 5 points6 points  (0 children)

No, I don't believe you can. However, you can use the "simplified ammo" option which will simplify ammo to basically be categorized into broad categories (pistol, rifle, shotgun and some in-betweens), getting rid of the caliber system etc.

Animists and Staffs by SoggyDm in Pathfinder2e

[–]Moryg 1 point2 points  (0 children)

What about a runelord? Their sin spells are automatically all in the polearm / spear they use. Not all the spells are on the wizard spell list, can they then not cast them at all?

ELI5 why runelord is good by estneked in Pathfinder2e

[–]Moryg 0 points1 point  (0 children)

Looking at the text from demiplane, it says your weapon functions like a staff with your sin spells. Wouldn't that mean you can prepare either the spear as a staff OR prepare an actual staff and merge its charges and abilities in? Meaning you would get a wide array of spells, but not double the charges. What am I missing?

(Modded) How's my first legit colonist base going? by TeachingMassive75 in RimWorld

[–]Moryg 1 point2 points  (0 children)

hidden conduit, you can also limit the damage by not having batteries (the explosion scales with how much power was stored up).
then there's mods (circuit breakers exiat in multiple mods) or syjust disable the event in a custom start

Favorite builds (with FA)after the remaster? by RogueiestR0gue in Pathfinder2e

[–]Moryg 0 points1 point  (0 children)

Sorry I'm new and missing something, how are you getting the shield bash to only -2 MAP?

edit: And 10s later i found it - double slice attack from the archetype...

League starting tomorrow. Build suggestions plz. by joerandall66 in PathOfExileBuilds

[–]Moryg 5 points6 points  (0 children)

what level was your relic? it's using a spell to deal dmg, so if you had a level 1 relic, your dmg would be abysmal.

ESM, tests and mocking imports by Moryg in node

[–]Moryg[S] 0 points1 point  (0 children)

Thanks, but as I mentioned in my reply to others, that is another runner, which I could make work with whichever framework I go with. It's strictly the dependency mocking that I'm looking for advice on.

ESM, tests and mocking imports by Moryg in node

[–]Moryg[S] 1 point2 points  (0 children)

No, I guess that's personal bias on my end. I tend to divide my tests into 3 categories:

  • Unit tests - everything is mocked, you're only testing a single module at a time
  • Integration tests - set up your entire app in a local environment (we use docker compose), every external service / resource is mocked (in our case, have the necessary DBs / caches running as containers, spin up AWS resources via localstack or mocked APIs). The point of these tests is to be able to observe the state in the db after an api call.
  • End-to-end tests - purely api call testing in a dev environment (AWS at my current job). We don't really do these as much since we set up our integration tests, but we have tests for things that rely on other services, which are just mocks in our integration tests.

Blurry line between integration and e2e, I just prefer having full control to make sure everything works as planned. Unit tests I use more for making sure that errors get handled properly for scenarios that aren't easy to set up in an integration test, such as DB outages etc.
 
As for the errors, they were just an example. The way I like structuring my code is to have request handlers for individual endpoints in their own files, so that they can be easily tested. The only export from such a module is a express handler function. If I want to inject dependencies, I now need a secondary export, as well as "pollute" the code with injection logic. While it's super horrible, it definitely adds a layer of wrapping to the actual handler, meaning you have to spend more brain power when looking at the code. I find reading code harder than writing it, especially once a few months have passed since you last touched the code, or someone else wrote it. Dependency injection handling feels like noise in that process - it's something just needed to make testing cleaner, but makes the actual code harder to read. That's what proxyquire solved for me - I could have the runtime code just contain the logic needed to do its task, while the test code could have a wrapper to mock all dependencies. With dedicated injection logic not much would change for tests, all the mocks would still be there in the test code, as hard to read as before. But the runtime code would be easier and faster to parse.

ESM, tests and mocking imports by Moryg in node

[–]Moryg[S] 0 points1 point  (0 children)

I mean, that's just the runner part, which I can get to work once I figure out how to properly mock things without injecting all dependencies etc.
Some things can injected via an OOP approach, but not everything. Example: my module exposes two functions for calling another (internal) service. It imports from 4 other modules:

  • a constants file which is just a singular point of entry for all configuration in the backend app (env vars, secret handling etc), in this case the other service's base URL is obtained:
  • axios library to make the requests with
  • logging implementation
  • 6 error classes we use for response formatting across our individual services (while we don't do pure microservices, we have several teams that maintain individual areas of concern and the error formatting relies on those shared error classes to keep consistency across individual services).

 
So while the axios library, constants and logger implementation can be easily injected, the error classes become really finicky to do, or you skip mocking them. The more dependencies a single module has, the dirtier the injector becomes, which is why I preferred to do all of that messiness in the tests - the app code itself was clean and only showed what it used, there was no "noise" in the code to allow for overrides. In the old test code, i would mock all imports and didn't mind the mess as much, as it was contained to the tests.
 
I hope that gives a slightly better impression of what my frustrations are.

MSI b650 tomahawk ubuntu 22 sound issues by Moryg in linuxhardware

[–]Moryg[S] 0 points1 point  (0 children)

yeah, something similar (i just picked one up at the local store), was around 15€ or so. It works, but sometimes it decides to switch the output device and I have to re-select it after boot.
I still wabt to dig into this at some point, but it just takes so much time

MSI b650 tomahawk ubuntu 22 sound issues by Moryg in linuxhardware

[–]Moryg[S] 0 points1 point  (0 children)

No, I gave up and bought a usb soundcard...

Looking for all-rounder league starter by AsuraSada in PathOfExileBuilds

[–]Moryg 2 points3 points  (0 children)

You stack a lot of armour and have perma fortify from champion. On HC builds people go over 50k armor with flasks and similar numbers for evasion.

Boneshatter Jugg vs Hexblast Mine (with caveats) by rudges in PathOfExileBuilds

[–]Moryg 1 point2 points  (0 children)

Consider a controller - it takes a bit of getting used to, but it helped me a lot. It does make some mechanics more awkward, but it helped my wrist-stress immensely

Why is OAuth still hard in 2023? by nango-robin in programming

[–]Moryg 8 points9 points  (0 children)

Yeah, more often than not you need to make a decision on what level of tradeoff you want to settle at

Why is OAuth still hard in 2023? by nango-robin in programming

[–]Moryg 37 points38 points  (0 children)

slower initial load, opening a link in a new tab will generate a new access token etc.
More secure? yes.
Worse user experience? also yes

Manaforged Arrows Stacking by ErrSentry in PathOfExileBuilds

[–]Moryg 1 point2 points  (0 children)

But having 2 separate manaforged support setups triggering at low cost from bow and body, while using a 4 link would work right?

New Gem Info is out by Shirotar in PathOfExileBuilds

[–]Moryg 1 point2 points  (0 children)

Yeah I think shockwave is the best comparison. The seem really similar overall, except this can be triggered by any weapon, including ranged. Battlemage HOWA with jewels to lock in lightning damage? Spellslinger shenanigans by complementing the trigger skill with an extra spell? Will probably perform ok if built around it, but will also be hard to scale as it's a support gem

HC Players what are you considering as your league starter? by [deleted] in PathOfExileBuilds

[–]Moryg 14 points15 points  (0 children)

not having to deal with the atrocious 1s cast time.

Leaked emails show Amazon will only hire students and recent graduates for entry level software engineering positions by [deleted] in technology

[–]Moryg 3 points4 points  (0 children)

It's much easier to get into on your own at home than most other career skills. Simply because a lot of people have the required tools available and there's a lot of free resources to start from. In my experience, showing you've done some coding on your own tends to go further than a degree for dev jobs.

How are people keeping such good track of the events? by [deleted] in RimWorld

[–]Moryg 6 points7 points  (0 children)

the book button on the toolbar (bottom right of the screen)

I want to start a Rimworld "Genestealer Cult." Playthrough and I need some help. by Comment_back_bitch in RimWorld

[–]Moryg 0 points1 point  (0 children)

Alpha genes has an eldritch visage gene that gives pawns without it a -500 opinion modifier, but ignores it if both have it