Using Storybook stories with Testing Library

Поделиться
HTML-код
  • Опубликовано: 2 фев 2025

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

  • @dominicnguyen5465
    @dominicnguyen5465 3 года назад +3

    This is a super helpful technique! Less mock duplication when you reuse stories in testing lib tests. Easier to maintain as well.

  • @davidfromnorth7836
    @davidfromnorth7836 3 года назад +7

    wow that's insane! Thank you! Definitely should play around this code. I should admit that you have very special and helpful content! Keep going!

  • @chaninator512
    @chaninator512 2 года назад +2

    This honestly needs more views

  • @jorgeduran1886
    @jorgeduran1886 3 года назад +1

    Wow, this is very worth knowing, I've never thought of this way of testing components, I'm surely gonna give it a try and keep up making cool videos like this

  • @danilocastro1281
    @danilocastro1281 3 года назад +2

    Awesome video! Content, explanation, and image quality. Thank you!

  • @Norfeldt
    @Norfeldt 2 года назад

    Thank you for making this video - it was really useful for me.

  • @ДмитрийКарпич
    @ДмитрийКарпич 2 года назад +1

    Oh, thank you for sharing this technique. It probably looks like a great alternative to the Cypress test (most of them).

    • @SwashbucklingwithCode
      @SwashbucklingwithCode  2 года назад +1

      No problem. And I think you'd still want Cypress for any E2E tests, these are more like unit and maybe integration tests depending on your setup.

  • @Apofisbg
    @Apofisbg 3 года назад +1

    Very useful video!
    Thanks a LOT

  • @licokr
    @licokr 2 года назад

    Amazing Video! Thank you, it really helped me. Easy explanation, and the detail, it's perfect

  • @mmmodel
    @mmmodel 3 года назад +9

    This guy it's the Jesus of the development

    • @tshawchit
      @tshawchit 3 года назад +1

      He probably gets that a lot outside development too 😂

    • @roberto9369
      @roberto9369 3 года назад +2

      People say that He didn't like to deploy new miracles on Fridays

  • @antonifkiara7332
    @antonifkiara7332 2 года назад +1

    Thanks homie

  • @AdityaShaw-qh1qc
    @AdityaShaw-qh1qc 10 месяцев назад

    What are the packages necessary to run the tests?

  • @arhamali20022002
    @arhamali20022002 2 года назад

    Which vs code icons you are using ?

  • @chrisvolonnino3567
    @chrisvolonnino3567 3 года назад +1

    what font and theme are you using for visual studio code?

    • @SwashbucklingwithCode
      @SwashbucklingwithCode  3 года назад +1

      The theme I use is Everset, which I created. I am not sure what the font was at the time but it might be Cascadia Code.

    • @chrisvolonnino3567
      @chrisvolonnino3567 3 года назад +1

      @@SwashbucklingwithCode You should add your theme to the marketplace! Cheers

    • @SwashbucklingwithCode
      @SwashbucklingwithCode  3 года назад +2

      @@chrisvolonnino3567 It's on the marketplace, here: marketplace.visualstudio.com/items?itemName=jimmydc.everset

  • @ashwinichougale3432
    @ashwinichougale3432 3 года назад +1

    How to display react test cases on storybook addon.

  • @josephlarsen
    @josephlarsen 3 года назад

    couldn't you use Default.args.slides[0] instead of hardcoding /swashbuckling/i into your test? That way you could use the array that's defined in your story in your test directly so that when it changes in the story it changes in the test automatically to match? Or will that not work?

  • @shashibhushanv6301
    @shashibhushanv6301 2 года назад +1

    This video is really help full. can you please make a video testing a component where you have .mdx and how we can interactive testing using play function, we are using the latest story book version 6.4
    I am using interactions add on and testing library but struggling to get my first test pass :(

    • @SwashbucklingwithCode
      @SwashbucklingwithCode  2 года назад

      I don't use MDX stories anymore due to them being a bit too finicky for me, but I used to like them a lot for documentation.
      I'm about to get more in depth on my current projects with play functions so if I make some breakthroughs I'll likely make a video on it.

  • @tony-ma
    @tony-ma 3 года назад

    do you use cypress for e2e testing? looking for some content on those. Or any testing in general. Testing javascript, in general, is harder than .NET backend (at least for me it is the case.). But with these tools and thanks to the model javascript. It is easier now.

    • @SwashbucklingwithCode
      @SwashbucklingwithCode  3 года назад

      I have used Cypress for that, yah. Frontend testing is full of challenges, for sure. Chromatic is a big leap forward for testing in general, and I hope to see more things like that for component level tests.

  • @Troy-ol5fk
    @Troy-ol5fk 2 года назад

    what are the benefits of using WSL ubuntu ?

    • @SwashbucklingwithCode
      @SwashbucklingwithCode  2 года назад +1

      For me, it's having my gaming machine, with easier/better video capturing and audio support, plus multi-monitor proper screen sharing support on calls or recording programs, be the same computer as my work where I prefer linux.
      KVM might seem like an option but it's quite difficult to get one with all of the features I need without it costing thousands of dollars (and then still missing stuff).
      Everyone has different preferences, so it for sure isn't for everyone, but I've tried so many different setups and this is the best for me right now.

  • @MsAnnieHuang
    @MsAnnieHuang 3 года назад +1

    Do we have the source code for this tutorial?

    • @SwashbucklingwithCode
      @SwashbucklingwithCode  3 года назад +2

      I'm a little late on this, but I've uploaded the code to a repo here: github.com/Jimmydalecleveland/storybook-tests-react

  • @vickylance
    @vickylance 3 года назад

    But how can I run just for a single file rather than entire directory?
    I would prefer in a tdd style manner where the coverage will report for the files that I run the test for because one it gives me immediate feedback on how much I am covering by my test cases and two the source code that I work on is very huge that it takes 56 mins to run the entire test coverage

    • @SwashbucklingwithCode
      @SwashbucklingwithCode  3 года назад

      Are you asking about just running the tests, or running the coverage report?
      For just running the tests, watch mode automatically attempts to only rerun tests for the files that you've changed.
      You can also use Jest filtering to only run specific files or tests by name.
      All that said, 56 mins seems like a very long time for a test suite, even one with a ton of files. It's possible that's normal for your use case, but I'd try to make sure all those tests are just unit tests (as opposed to integration tests), and aren't waiting for long async calls.

    • @vickylance
      @vickylance 3 года назад

      @@SwashbucklingwithCode I was thinking of running jest in watch mode along with the coverage report of the file/files it's currently running test in. I think filtering will do but it would be better if it takes the file name as argument and runs the coverage also only in that file when running in watch mode that will make it easier for TDD as I then don't have to check coverage before committing

    • @SwashbucklingwithCode
      @SwashbucklingwithCode  3 года назад +1

      @@vickylance I haven't had much success with the accuracy of coverage + watch mode, but I haven't put a ton of effort in either.
      I also use Husky to run precommit hooks that check coverage and tests passing on any code that has changed.

  • @sanjeevmerugu2398
    @sanjeevmerugu2398 2 года назад

    how to write testcases in angular storybook

    • @SwashbucklingwithCode
      @SwashbucklingwithCode  2 года назад

      I don't use Angular but there is a Testing Library for Angular package so I don't imagine it'd be different at all:
      testing-library.com/docs/angular-testing-library/intro/

  • @super4prikolist1
    @super4prikolist1 2 года назад +1

    Jesus' opinion is always worth it, thanks !

  • @hyfydistro
    @hyfydistro 3 года назад

    I've heard of "End to End" or E2E testing but I'm not sure how to go about it. Another nice video btw!

    • @SwashbucklingwithCode
      @SwashbucklingwithCode  3 года назад +1

      I'm still planning out how I want to cover the rest of the "testing" topic, but E2E can be tricky because it is quite dependent on your setup and needs. I'm also still learning in that area.

    • @hyfydistro
      @hyfydistro 3 года назад

      @@SwashbucklingwithCode I'm aware of Unit Testing, Integration Testing and E2E but I'm not sure what qualifies as it. I'm not sure when to use it either or how to put it in my development workflow. I hope that gives you an idea. I'm still new to it! 😁

    • @SwashbucklingwithCode
      @SwashbucklingwithCode  3 года назад +1

      @@hyfydistro This is useful to know, thank you for elaborating.

    • @davidfromnorth7836
      @davidfromnorth7836 3 года назад

      ​@@hyfydistro Hey! Check out cypress! Great for e2e testing!

  • @santhoshraghavpidathala3701
    @santhoshraghavpidathala3701 3 года назад +3

    Please note down my request on promises(all, race, etc...), async await, generators with real time example. Please don't do example with setTimeout, etc...

  • @fardeenpanjwani8160
    @fardeenpanjwani8160 3 года назад +1

    Dude low key looks like Jared Leto. Great tutorial though.

  • @asgard-hehe
    @asgard-hehe Год назад

    jesus

  • @graezzywormz1438
    @graezzywormz1438 2 года назад

    jesus criest