Artem Zakharchenko
@kettanaito.com
4K followers 200 following 3.6K posts
Software engineer. Helping you master automated testing at http://EpicWeb.dev. Author mswjs.io. Instructor egghead.io. I tell stories @zakarcher.com. My debut book "LOGGERHEADS" it out 👇 https://zakarcher.com/books/loggerheads
Posts Media Videos Starter Packs
Pinned
kettanaito.com
Huge news! I've written a book.

This is a story of light and dark that won't leave you indifferent. Illustrated, atmospheric, and meaningful. The kind that stays with you.

Please enjoy this cover reveal for Loggerheads:
zakarcher.com/blog/cover-...

📚💙
Cover reveal: Loggerheads
zakarcher.com
kettanaito.com
From my experience, whenever I had tests failing in headless was because running in headful mode is generally slower, and that slowness was offsetting the race conditions my tests (incorrectly) had.
kettanaito.com
Do you remember an example of such a test?
The cause is usually in the test itself, is it not?
kettanaito.com
They are not the same though. You do not reach to bind/apply/call if you just want a function call. You usually reach to them because you want to invoke the function with a different context. Or create a bound function. I can't say they compare at all since they do different things.
kettanaito.com
No one uses it in enterprise code and for the better. Quite a few usages in open source though. There are also times when you *have to* use it. Things like:

callback(obj.method)

Better not forget to rebind method to object or here come bugs.
kettanaito.com
target esnext, module esnext, nothing else that I can tell.
kettanaito.com
But if you are talking about runtime values, well, that can be said about the entirety of TypeScript anyhow.
kettanaito.com
TypeScript begs to differ.
kettanaito.com
Both. Awesome reply! Thanks!
kettanaito.com
Only if you be there to meet you, François!
kettanaito.com
Inspiring but not helpful 😅 Trying to see what kind of struggles I'm missing to address.
kettanaito.com
Wow so few of you actually knew you can type "this" in TypeScript and it's NOT an argument. I need to talk more about API design.
kettanaito.com
If they have me! Thanks for the recommendation, Dominik!
kettanaito.com
What were the top 3 things that confused you when you started writing automated tests?
kettanaito.com
If I crack the new MSW architecture, I'd like to give a 30m talk about it.

Which conference should I talk about this at?
kettanaito.com
All the existing APIs have been rewritten to the new architecture in MSW. All the tests are passing. We're truly onto something!

Now, let's see how it fares against this new crazy thing...
kettanaito.com
From where I stand, an optimal DX seems like a mixture of classes and functions. It doesn't have to leak to the consumer, as you can wrap classes in instantiating functions (like we're doing already with `setupWorker`, for example). Cannot say it's perfect but well.
kettanaito.com
Functions do suck at behavior composition. I'm not talking about functional composition here. z(y(x()) is great, apart from the thing that very few people in webdev even understand what I just wrote. I'm talking primarily about fn returning an object which methods extend base().
kettanaito.com
Functions, on the other hand, don't suffer from the inference issues and you can expose a `defineXYZ` pattern that will infer, say, the argument/return types of the methods from the returned object gracefully. I love that.
kettanaito.com
Where classes fall short is in TypeScript. I bugs me that there's no method argument type inference at all. You have to re-type your methods even if you don't deviate from the base class. Extremely annoying and yields terrible DX as a public API.
kettanaito.com
Classes are really great for, surprise-surprise, inheritance! Tapping into `super` is a powerful way to compose functionality. Classes are also unmatched for "here's a boilerplate for a behavior" (aka plugin systems).
kettanaito.com
There are things that classes do better. There are things that functions do better. But mixing both within the same API feels clanky. Conflicted about this.
kettanaito.com
iirc, I have trusted publishing set up but I still need a token to actually publish. Aren't those layers to the process, not exclusives?
kettanaito.com
Does that not defeat the purpose of expiring tokens being safe?