End-to-end testing

Hi,

how do you test your stuff?

You know the usual web testing like

  • do something
  • expect something in the DOM

We can’t really do that because everything is in a single DOM element, the canvas.
But, we could expect something to happen in the scene, right?

I imagine pretty much every JS testing framework could do, with some (plenty?) customization.

Which framework you use, and how do you customize do something and expect something to test your Babylon apps?

I don’t do unit testing on personal projects … just because :smiley:

However for previous jobs I’ve used jest/vitest and Babylon NullEngine.

Once you’ve instantiated Babylon with NullEngine in your test files, you can simply modify and interrogate the scene graph to ensure nodes, structure and properties change as expected.

You can take a look at the Babylon.js unit tests in the repo to get you started:

2 Likes

Thanks, looking into it!

Note that I asked about end-to-end rather than unit testing.
Manly because visual things can easily pass unit tests, and E2E frameworks save screenshots or record videos of everything.
And also, folks doing web apps tend to use some E2E framework already, like playwright, cypress, etc.Because they need to test their UI logic and business logic both, both client-side and server-side.

Here, a specific example. I had this bug for months, at least, and I wonder since when :slight_smile:

I use playwright for screenshot comparison testing to catch visual regressions:

For unit tests, I use vitest, but it’s mostly for the non-babylon logic parts. I should probably use the NullEngine more though ^^

1 Like

Ah cool, so you could evaluate some js, wait a bit, then screenshot compare, thanks!

And, beautiful game!

1 Like

Yes that’s the plan, but handling animated objects is not trivial as there can be small differences in delta time that mess up the comparisons.