Maybe we can add correct output about result of `npm run build:dev`?

Now I read the doc about contribution Start Contributing to Babylon.js | Babylon.js Documentation
And it is written here

It is recommended to run npm run build:dev before starting to work to make sure everything is in the right place.

But what is the correct output of this command? What I should to see if all is fine, or what when something is wrong?

For example, now I have this output:

$ npm run build:dev

> @babylonjs/root@1.0.0 build:dev
> npm run build:assets && npm run build:source && npm run build:declaration -w @tools/babylon-server


> @babylonjs/root@1.0.0 build:assets
> build-tools -c pa --global

Babylon.js build tools
Command: pa
Processing assets from ./packages/**/*/src/**/*.+(png|jpg|jpeg|gif|svg|scss|css|html|json|fx)

> @babylonjs/root@1.0.0 build:source
> tsc -b ./tsconfig.devpackages.json


> @tools/babylon-server@1.0.0 build:declaration
> build-tools -c pud --config ./declarationConfigDev.json

Babylon.js build tools
Command: pud
declaration file generated [ '@dev/core' ]
declaration file generated [ '@dev/gui' ]
 IArrayItem as IArrItem
 IGLTFLoaderExtension as IGLTFBaseLoaderExtension
declaration file generated [ '@dev/loaders' ]
declaration file generated [ '@dev/inspector' ]
declaration file generated [ '@tools/node-editor' ]
declaration file generated [ '@tools/gui-editor' ]
declaration file generated [ '@tools/ktx2decoder' ]
declaration file generated [ '@dev/serializers' ]
declaration file generated [ '@dev/materials' ]
declaration file generated [ '@dev/post-processes' ]
declaration file generated [ '@dev/procedural-textures' ]

Is it OK? Or something wrong? Or something missing?
Maybe we can add correct output right in the docs? Probably it can be hidden under the spoiler.

well, the question is what do you expect it to do, and what you do with the result?
This will compile all of our dev packages. they are not used directly but released using public packages or served using the babylon server.
What are you trying to do?

In general my question about right expectation of this command. What is this should to show and what is this should not to show?

In my local task I want to run unit tests.
I forked the repo, clone, run npm install and check npm run build:dev. After this I run npm run test:unit and got this:

Test Suites: 10 failed, 7 passed, 17 total
Tests:       35 passed, 35 total
Snapshots:   0 total
Time:        3.907 s, estimated 22 s
Ran all test suites.

I think it is not correct output, I didnt change anything but some of tests are failed. As I can see, some trouble with import “WebGPU/webgpuMaterialContext”. Probably I skip some steps, I dont know… :thinking:

D:\OSPanel\domains\Babylon.js\packages\dev\core\src\Engines\WebGPU\webgpuMaterialContext.ts:44
            this.isDirty ||= isDirty;
                         ^^^

    SyntaxError: Unexpected token '||='

      36 | import { WebGPUDepthCullingState } from "./WebGPU/webgpuDepthCullingState";
      37 | import { DrawWrapper } from "../Materials/drawWrapper";
    > 38 | import { WebGPUMaterialContext } from "./WebGPU/webgpuMaterialContext";
         | ^
      39 | import { WebGPUDrawContext } from "./WebGPU/webgpuDrawContext";
      40 | import { WebGPUCacheBindGroups } from "./WebGPU/webgpuCacheBindGroups";
      41 | import { WebGPUClearQuad } from "./WebGPU/webgpuClearQuad";

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
      at Object.<anonymous> (packages/dev/core/src/Engines/webgpuEngine.ts:38:1)

The unit tests compile typescript, so it has little to do with the build:dev command. jest seems to not like the syntax you have used (though it is es2021 conform). This is more a jest issue than the build:dev command.

The build:dev command builds all of the dev packages. that’s about it. it is not used by the tests, and is not used when hosting the local babylon-server.

Sorry,

i just realized you wrote that you didn’t change anything and the tests are failing.
What node/npm are you running? have you updated dependencies lately?

Yep, I just hoped that build:dev says me if I had errors with installed packages. And if build successfull, so I expect that other commands should work also.

sadly that’s not the case. jest uses its own typescript compiler (and target). Apart from that everything else uses the same tsconfig, so it should be good to go.

$ node -v
v14.17.0

$ npm -v
8.18.0

At the root dir I ran npm ci so currently I dont have any changed file.

and you just ran the tests and they fail?

Yes, seems like error in the ||= operand, I’ll try to check tsonfig target

our CI works well, so it is rather odd to me that you have this issue.
I’ll investigate tomorrow as well.

1 Like

image

Seems to be all good here.
What command are you running? npm run test:unit ?

Yes, it is. My clone of repo here GitHub - Dok11/Babylon.js: Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed into a friendly JavaScript framework.
And I still trying to find the reason of my trouble :smiley:

The Jest trying to say smth, but I am not sure that any of suggested decision is acceptable in my case

FAIL unit packages/dev/core/test/unit/Animations/babylon.animationGroup.test.ts
● Test suite failed to run

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
 • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
 • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation

Details:

D:\OSPanel\domains\Babylon.js\packages\dev\core\src\Engines\WebGPU\webgpuMaterialContext.ts:44
        this.isDirty ||= isDirty;
                     ^^^

Via PhpStorm (from them interface) I can run some unit tests from the test file directly.
But interesting — it.each() is not working, and in the source code i didnt found any usage of each function. If I use two testcases in the each with one succefull and one wrong paramateres, then tests will failed only if wrong test case was first.

In this case test will filed

it.each([
  { expected: false },
  { expected: true },
])(({expected}) => {
  expect(expected).toEqual(true);
});

But if I switch items in the array then tests will pass. :thinking:

Sorry, this is very hard for me to debug, especially since it is working on every system I have tried it on. The core babylon developers use different environments as well, and we have never experienced that.
Running npm run test:unit should use the local jest installation. Is it possible you have a global version of jest that is older?

Don’t worry about, definitely it is problem on my side.

I run npx jest -v and version of Jest is same as in the package.json.
That is your npm and node versions?

And do you know about it.each, does it work on your system?

test.each is a part of the jest API (this is actually why i asked about the version):

I run npx jest -v and version of Jest is same as in the package.json .
And one interesting point - I wrote above:

Test Suites: 10 failed, 7 passed, 17 total
Tests:       35 passed, 35 total
Snapshots:   0 total
Time:        3.907 s, estimated 22 s
Ran all test suites.

And it was on the node version 14.17.0. Now I install npm 16.17.0 and npm run test:unit shows this:

Test Suites: 1 failed, 16 passed, 17 total
Tests:       53 passed, 53 total
Snapshots:   0 total
Time:        4.969 s, estimated 10 s
Ran all test suites.

:thinking: :thinking: :thinking:

Now failed just one test with:

FAIL unit packages/dev/core/test/unit/XR/webXRFeaturesManager.test.ts
  ● Test suite failed to run

    The module '\\?\D:\OSPanel\domains\Babylon.js\node_modules\canvas\build\Release\canvas.node'
    was compiled against a different Node.js version using
    NODE_MODULE_VERSION 83. This version of Node.js requires
    NODE_MODULE_VERSION 93. Please try re-compiling or re-installing
    the module (for instance, using `npm rebuild` or `npm install`).

      at Object.<anonymous> (node_modules/canvas/lib/bindings.js:3:18)

UPD. After this I reinstall node modules and all tests are passed! :smiley:

So, is node -v 16 required to develope? @RaananW

In this article Start Contributing to Babylon.js | Babylon.js Documentation I dont see requirements about node version.