Node.js version 20 comes with a new, built-in, stable test runner. This post takes a look into what you can do with it, with a small example test project.

  • Lachy@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    What was even the point of introducing the legacy assertion module? We’ve known for decades that using == is not a good idea. They should have just killed it while the thing is experimental, instead of letting it get into the stable module.

    The extra effort required to explicitly import the strict assertion module, instead of getting it by default, is going to lead to lazy developers inadvertently getting the legacy mode, that shouldn’t exist for a new assertion module.

    • philnash@programming.devOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      I think you’re absolutely right about the difficulty for developers inadvertently getting the legacy assert behaviour. Though I hope if they do that, they at least recognise that they can use the strict methods.

      The early module had both non-strict and strict methods, even from that early time, so the original author recognised the need for using ===, but I guess wanted to be flexible and allow for == usage too. Perhaps this was a bad decision, but it was made in version 0.1.21, so I would guess there was a lot of fast work going on with Node at the time and maybe not everything was thought through in as much depth as it could be. It’s possible that one day the strict module may take over the place of the existing assert module, but that would be quite the breaking change!