Using 'using' for unit tests

Поделиться
HTML-код
  • Опубликовано: 30 янв 2024
  • НаукаНаука

Комментарии • 23

  • @nagarajansubramani
    @nagarajansubramani 5 месяцев назад +20

    C# users are extremely familiar with 'using' and it is darn nice to finally have it in JS.

    • @jongeduard
      @jongeduard 4 месяца назад +1

      Basically many modern and actually good features are in JS are C# things. Just think about the lambda arrow notation, which C# had far longer since it's version 3 around the year 2008.
      Not so strange since TS also comes from Microsoft and has a huge influence on actual JS too.
      It's on top of all the bad old legacy 90s design problems such as weird type coercions and other weirdnesses that JS also has though. But that's another subject too long for this comment section.
      Also important to note that most languages have similar solutions though. Java has try-with-resources and Python has a with statement.
      Other languages rely on actual RAII instead and do not even need extra keywords. Such as Rust.

    • @sk_jay
      @sk_jay 4 месяца назад

      Aync ,Await has been in c# before js implemented it...

    • @jongeduard
      @jongeduard 4 месяца назад

      @@sk_jay True, most people do not even know about C# or refer to it, and often they mention JS.
      However, I am not sure if the TPL is also older than JS Promises, which are both the unlying concurrency libraries.
      Dotnet Framework 4 introduced TPL, and 4.5 introduced the actual async await syntax later.
      If I am right Node JS already came with the first implementation of Promises around 2009.
      Not that we can fully compare them, as JS is single threaded, but you get the idea.

  • @lachezarraychev1391
    @lachezarraychev1391 5 месяцев назад +1

    Matt is just awesome! I Love everything he does for us.

  • @juliohintze595
    @juliohintze595 5 месяцев назад +1

    Hey Matt, you're my favorite RUclipsr when it comes to programming in general. Always straight to the point, with VERY useful tips.
    Every post/video of yours is worth our time!

  • @mich_thedev
    @mich_thedev 4 месяца назад

    The beanie looks good on you matt

  • @WillDelish
    @WillDelish 5 месяцев назад

    This seems pretty fancy

  • @truth8690
    @truth8690 5 месяцев назад

    Cool

  • @Thorax232
    @Thorax232 5 месяцев назад +3

    I love this tip. But this video is way too meta.

  • @mrzachnugent
    @mrzachnugent 5 месяцев назад +6

    using hat = changeThingsUp()

    • @DefekacjaOdbyta
      @DefekacjaOdbyta 4 месяца назад

      I would expect then the hat to be disposed at the end of the video.

    • @mich_thedev
      @mich_thedev 4 месяца назад

      ​@@DefekacjaOdbytayou spitting fire 😂😂

  • @shapelessed
    @shapelessed 4 месяца назад

    Amazing.
    Now wait till it actually works in JS.

  • @marcusrehn6915
    @marcusrehn6915 5 месяцев назад

    Foo fancy and non-obvious for my liking

  • @mickmister
    @mickmister 4 месяца назад

    I'm using the jest runner vscode extension, and it doesn't recognize the `using` keyword. When I introduce the keyword to my test file, the "run test" hints above each test definition disappear. Any thoughts on this?

    • @mattpocockuk
      @mattpocockuk  4 месяца назад +2

      File an issue, they'll need to update the extension

  • @viewtifult
    @viewtifult 5 месяцев назад

    What is the advantage of just using beforeEach or AfterEach

    • @mattpocockuk
      @mattpocockuk  5 месяцев назад

      It makes the tests less portable and harder to read.

  • @ColinRichardson
    @ColinRichardson 5 месяцев назад

    That is the wrong type of hat.. It's meant to be a Top Hat..
    (Still waiting for your head size)

  • @aleksd286
    @aleksd286 4 месяца назад

    Please give a real example

    • @mattpocockuk
      @mattpocockuk  4 месяца назад

      www.totaltypescript.com/typescript-5-2-new-keyword-using

  • @sobanya_228
    @sobanya_228 4 месяца назад

    It's not even on mdn