Тёмный

I didn't know snapshot testing was a thing 

Joshua Morony
Подписаться 78 тыс.
Просмотров 4,9 тыс.
50% 1

Опубликовано:

 

31 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 24   
@JoshuaMorony
@JoshuaMorony 8 месяцев назад
I have a newsletter if you want to join: mobirony.ck.page/4a331b9076
@123456crapface
@123456crapface 8 месяцев назад
I saw this video yesterday and started incorporating snapshotTesting for this query parser I am writing in js. it consumes and returns massive jsons and before i was printing the result and copy pasting that into my code and modifying as needed. this is so much cleaner and easier. I was able to iterate 3-5 times faster in this specific case. thank you sir
@sakesun
@sakesun 8 месяцев назад
Magical audio is one of the secret recipe of this channel content.
@FlyingPenguino
@FlyingPenguino 8 месяцев назад
Consider making a video about screenshot testing 😊
@havokgames8297
@havokgames8297 8 месяцев назад
Neither did I. Great overview thanks.
@jeffnikelson5824
@jeffnikelson5824 8 месяцев назад
I totally see the benefit in checking json data but updating the snapshot of a template in a tdd cycle before I actually to the changes to the template feels somewhat awkward.
@Dajuhf
@Dajuhf 8 месяцев назад
Seems interesting but, idk, seems that some team member would only update the snapshot (for purpose or only mistakenly) and the tests that should be fine now have a error that seems a hell to fix if you're not part of the situation.
@havokgames8297
@havokgames8297 8 месяцев назад
You should be catching this in code review if so.
@PaulSebastianM
@PaulSebastianM 8 месяцев назад
​@@havokgames8297ha ha yeah right.
@anj000
@anj000 День назад
If someone will update only snapshot then it will fail immediately and CI/CD will catch that on PR level.
@FlyingPenguino
@FlyingPenguino 8 месяцев назад
I personally don't like snapshot testing like this because the intent of such test could be lost (what business cases you're checking). Also doesn't it violate the "don't test the internals" guideline of TDD? I mean, everytime you change the source code, you'll have to update the snapshot too. I guess it's all about what kind of problems you want to avoid during development cycle of the product. But yeah, if you really want to store snapshots of your code - - you're already doing that with Git (kinda)
@JoshuaMorony
@JoshuaMorony 8 месяцев назад
To be clear, the snapshot is of a static example template defined within the test itself, it's not testing the source code of an application it is testing how one (or a few) particular example template strings are transformed. So the tests will keep passing and the snapshots won't need to be updated as long as the schematic keeps doing what it is supposed to be doing - the implementation of the schematic could even be changed without the snapshot being updated as long as the behaviour of the schematic remains unchanged
@hollowbug2443
@hollowbug2443 8 месяцев назад
Oh my god, I can understand snapshotting UI Elements for regression testing but snapshotting the code itself, what is this madness?! 😂
@JoshuaMorony
@JoshuaMorony 8 месяцев назад
It's snapshotting the result of a transformation on a string that just happens to be code - we expect that if we pass this function a string representing code, it will transform that string to modify that code in a particular way
@hollowbug2443
@hollowbug2443 8 месяцев назад
@@JoshuaMorony ah, okay - I didn't get that information when I skimmed through the vid, makes more sense now
@001HK0
@001HK0 8 месяцев назад
I worry that this could make writing a lot of fragile tests that don't get at the underlying functionality more appealing because of how easy it is to ignore them every release by --updateSnapshot'ing every time. Obviously "good devs" won't do this on purpose, but it could happen unintentionally with some meager justification.
@JoshuaMorony
@JoshuaMorony 8 месяцев назад
You will be able to see the diff for the snapshot file when reviewing the PR though, and unless reviewers just aren't paying attention (which is its own problem) it should be caught if a dev were trying to "cheat" the test - but yes it would be possible for something to slip by, but I think this is more of a dev problem then a problem with the approach in general
@001HK0
@001HK0 8 месяцев назад
@@JoshuaMorony Yes, that makes sense.
@dafemele10
@dafemele10 7 месяцев назад
Sorry for spamming, i wanna ask again, what font are you using?
@JoshuaMorony
@JoshuaMorony 7 месяцев назад
It's MesloLGS NF
@adambickford8720
@adambickford8720 8 месяцев назад
You should be testing what you want, not what you did. Conceptually, this feels backwards.
@johalternate
@johalternate 8 месяцев назад
In this case, the snapshot is exactly what you want.
@brandongregori995
@brandongregori995 8 месяцев назад
If I'm understanding it correctly, the snapshot is the output of whatever you are testing. So you can do a snapshot of a function return, or of your component UI. The latter imo makes the most sense, because I can see that the UI looks good after some change is made, and I just want that state to be remembered and tested against so I don't need to write a whole bunch of tedious tests.
@JoshuaMorony
@JoshuaMorony 8 месяцев назад
This still feels like "testing what you want" to me. If we take this example back to the beginning, before any code has been implemented yet, I create a snapshot of the result of the "readContent" function which will output nothing or just return the string unchanged. I edit the result of the snapshot to what I want it to be, and then get to work on making the function output the correct result. Alternatively, with less of a TDD approach, you make the transform work how you want up front, then take the snapshot to ensure the transformations you are supporting aren't broken in the future. This is still very valid and useful imo.
Далее
The mindset you need for a DECLARATIVE code refactor
7:56
The easier way to code Angular apps
9:54
Просмотров 68 тыс.
Angular change detection explained in 5 minutes
6:06
The Joy of Testing by Victor Rentea
2:45:36
Просмотров 7 тыс.
The perfect use case for RxJS... violins?
9:26
Просмотров 8 тыс.
Tutorial. Snapshot Testing
15:02
Просмотров 280
Why did we need Signal Inputs in Angular, again?
12:19
Просмотров 1,9 тыс.
Angular Testing in 2023: Past, Present, and Future
26:21
So You Think You Know Git - FOSDEM 2024
47:00
Просмотров 1,2 млн