RaananW / babylonjs-webpack-es6

Babylon.js basic scene with typescript, webpack, es6 modules, editorconfig, eslint, hot loading and more. Will even make coffee if you ask nicely.
Apache License 2.0
189 stars 99 forks source link

[Feature Request] Test structure #23

Closed yuripourre closed 1 year ago

yuripourre commented 2 years ago

This repo saved me a lot of time setting a new project, thank you so much for your efforts.

I think the only step missing to have the perfect template repo is the test structure.

I added tests to my private fork but it doesn't look very good, maybe someone with more experience with typescript would be able to come with a proper solution.

RaananW commented 2 years ago

Oh, I have a plan to create a visualization test suite for babylon.js projects. I can add it here as well :-)

Might take a while (as always), but this is a wonderful addition.

yuripourre commented 2 years ago

@RaananW looking forward to it! No rush, if I find a cleaner way to add tests meanwhile, I can open a PR.

unicomp21 commented 1 year ago

What about jest type testing in the browser? Can we do that too?

unicomp21 commented 1 year ago

@RaananW grateful for you! I was hanging by my last neuron, until I found this repo. Now, life is bliss, lol.

RaananW commented 1 year ago

running npm run test will now launch playwright validation tests in chrome for the scenes.

Note that if you want the validation tests to be deterministic, make sure you add some event or an observable you can hook into to decide when to take the screenshot.

unicomp21 commented 1 year ago

I'm not familiar w/ playright, does jest-like tests too?

RaananW commented 1 year ago

https://playwright.dev/

RaananW commented 1 year ago

Sorry, submitted too early :-)

It is an in-browser testing framework. It's not jest, but has a very similar API.

I think unit-testing for a babylon scene is a little less needed. If it is I can add jest configuration - but I don't see any proper unit test I can add to this repo

unicomp21 commented 1 year ago

I would be grateful for jest. I'm working on procedural generation tooling, which is nothing but vector math. Having both would be awesome.

yuripourre commented 1 year ago

@RaananW I don't want you to have more work but I second @unicomp21. I rely on jest tests a lot, I could port my changes to this repo but I changed my fork too much.

RaananW commented 1 year ago

All you need is a proper jest configuration if you want to run unit tests in this repo. I'd be more than happy to suggest, however, from experience, a 3D experience is better tested using visual tests and not unit tests.

I'll add the config very soon

unicomp21 commented 1 year ago

@RaananW at a high level, agree 100%. But for automated testing of primitives, ie something like Vector3.cross(), jest tests makes sense at this level, right? The stuff I'm working on involves primitives, which don't yet exist in babylon.js

RaananW commented 1 year ago

A working jest config was added, able to load esm, typescript, and babylon.

unicomp21 commented 1 year ago

Many thanks @RaananW, appreciate you!

yuripourre commented 1 year ago

Thank you @RaananW !!