Hello everyone
I would like to test my project with Jest framework. Problem wen I run the test, the canvas element was undefined. I think it should be mock canvas, but I don’t know how doing it.
Sorry for my bad English, if you don’t understand something or you need more detail ask me.
I can explain in french if you want.
Thank you for your help
My project :
index.js:
index.test.js:
Result of my test:
Well, I do not know Jest precisely but you definitely need to create a DOM canvas named renderCanvas
1 Like
Yes, but I do not know how to do that did anyone ever make it? even without jest?
if you only need to do unit testing, you should use the NullEngine and not attach your camera
This is what we do for all our unit tests on babylon.js CI
1 Like
The unit test is to test the code as it is. If I change the code so that the tests work, it no longer matters. And it won’t work anymore when I push my tests on a pipe line so that it will launch when I push my code on github
Yes but if it involves a rendering then you need to provide a canvas
1 Like
So question is more for Jest forum (if that exists :))
1 Like
Jest don’t have forum but I’m going to post my question on stackoverflow
Thx for your answer
1 Like
Merci beaucoup David, j’ai cherché pendant pas mal d’heures des façons de tester mon projet Babylon, NullEngine est exactement ce que je veux !
J’ai testé plein de choses : mocker avec sinon, des lib de mock de webGL etc …
Vous devriez le documenter quelque part dans la doc de babylon, ça éviterait aux prochains de chercher pendant longtemps !
J’ai fais un projet avec Babylon en typescript, c’est vraiment un bonheur votre moteur J’avais jamais fais de 3D et c’est super simple, merci pour tout ça.
2 Likes
This is the best kind of message we can receive Always a huge pleasure to read that.
Tout a fait entre nous, je m’attendais au fond de moi à une réponse de ce genre Mais je l’ai pas trouvé, pourtant maintenant que je sais quelle page c’est, je la trouve en cherchant sur google. Anyway merci à vous et longue vie à BabylonJS et longue vie à l’open source !
1 Like