Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests on Node.js don't run locally (on Windows?) #23424

Closed
takahirox opened this issue Feb 4, 2022 · 16 comments · Fixed by #23505
Closed

Unit tests on Node.js don't run locally (on Windows?) #23424

takahirox opened this issue Feb 4, 2022 · 16 comments · Fixed by #23505

Comments

@takahirox
Copy link
Collaborator

Describe the bug

The unit tests on Node.js don't run locally. They seem to run on CI server, so it might be a platform specific issue? (Refer to the Platform section below for my environment.)

To Reproduce

Steps to reproduce the behavior:

  1. $ npm install
  2. $ npm install --prefix test
  3. $ npm run test-unit

Error log:

$ npm run test-unit

> three@0.137.5 test-unit
> npm run unit --prefix test


> test-deps-intaller@1.0.0 unit
> qunit -r failonlyreporter -f !-webonly unit/three.source.unit.js

not ok 1 global failure
  ---
  message: "No tests matched the filter \"!-webonly\"."
  severity: failed
  actual: undefined
  expected: undefined
  stack: "Error: No tests matched the filter \"!-webonly\".\n    at done (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\qunit\qunit.js:2074:17)\n    at advanceTestQueue (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\qunit\qunit.js:1985:7)\n    at Object.advance (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\qunit\qunit.js:1940:7)\n    at unblockAndAdvanceQueue (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\qunit\qunit.js:4321:21)"
  ...
1..2
# pass 0
# skip 0
# todo 0
# fail 2

-f !-webonly may be unrelated. Even if I remove that filter, the tests still don't run.

$ npm run test-unit

> three@0.137.5 test-unit
> npm run unit --prefix test


> test-deps-intaller@1.0.0 unit
> qunit -r failonlyreporter unit/three.source.unit.js

not ok 1 global failure
  ---
  message: "No tests were run."
  severity: failed
  actual: undefined
  expected: undefined
  stack: "Error: No tests were run.\n    at done (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\qunit\qunit.js:2082:17)\n    at advanceTestQueue (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\qunit\qunit.js:1985:7)\n    at Object.advance (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\qunit\qunit.js:1940:7)\n    at unblockAndAdvanceQueue (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\qunit\qunit.js:4321:21)"
  ...
1..2
# pass 0
# skip 0
# todo 0
# fail 2

Expected behavior

The tests run locally.

Platform:

  • Device: Desktop
  • OS: Windows 10
  • Three.js version: dev
  • Node.js (node.js v16.13.2, npm 8.1.2), Git Bash
@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 4, 2022

I can reproduce the issue on a Windows 10 laptop with node.js 17.4.0.

The tests run as expected on macOS.

@marcofugaro
Copy link
Contributor

marcofugaro commented Feb 4, 2022

Tip:

if you run

qunit -f !-webonly unit/three.source.unit.js

you can see the actual error.

If that doesn't work, try

qunit unit/three.source.unit.js

The "No tests matched the filter ... is just a generic error that qunit + failonlyreporter outputs

@takahirox
Copy link
Collaborator Author

@marcofugaro Thanks for the advice but as written in the issue comment

-f !-webonly may be unrelated. Even if I remove that filter, the tests still don't run.

@marcofugaro
Copy link
Contributor

@takahirox I was suggesting you remove -r failonlyreporter, that's what's blocking the error.

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 4, 2022

I see this now:

not ok 1 global failure
  ---
  message: |+
    Error: Failed to load file unit/three.source.unit.js
    Error: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
  severity: failed
  stack: |
    Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
        at new NodeError (node:internal/errors:371:5)
        at throwIfUnsupportedURLProtocol (node:internal/modules/esm/resolve:996:11)
        at defaultResolve (node:internal/modules/esm/resolve:1070:3)
        at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
        at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
        at ESMLoader.import (node:internal/modules/esm/loader:332:22)
        at importModuleDynamically (node:internal/modules/cjs/loader:1036:29)
        at importModuleDynamicallyWrapper (node:internal/vm/module:437:21)
        at importModuleDynamically (node:vm:381:46)
        at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)

@takahirox
Copy link
Collaborator Author

Ah, my bad. It seems Windows file path problem?

$ npm run test-unit

> three@0.137.5 test-unit
> npm run unit --prefix test


> test-deps-intaller@1.0.0 unit
> qunit -f !-webonly unit/three.source.unit.js

not ok 1 global failure
  ---
  message: |+
    Error: Failed to load file unit/three.source.unit.js
    Error: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
  severity: failed
  stack: |
    Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
        at new NodeError (node:internal/errors:371:5)
        at defaultResolve (node:internal/modules/esm/resolve:1016:11)
        at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
        at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
        at ESMLoader.import (node:internal/modules/esm/loader:276:22)
        at importModuleDynamically (node:internal/modules/cjs/loader:1041:29)
        at importModuleDynamicallyWrapper (node:internal/vm/module:437:21)
        at importModuleDynamically (node:vm:381:46)
        at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
        at run (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\src\cli\run.js:86:6)
  ...
Bail out! Error: Failed to load file unit/three.source.unit.js
TAP version 13
not ok 2 global failure
  ---
  message: "No tests matched the filter \"!-webonly\"."
  severity: failed
  actual  : undefined
  expected: undefined
  stack: |
    Error: No tests matched the filter "!-webonly".
        at done (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\qunit\qunit.js:2074:17)
        at advanceTestQueue (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\qunit\qunit.js:1985:7)
        at Object.advance (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\qunit\qunit.js:1940:7)
        at unblockAndAdvanceQueue (C:\Users\Takahiro\Documents\three.js\test\node_modules\qunit\qunit\qunit.js:4321:21)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
  ...
1..2
# pass 0
# skip 0
# todo 0
# fail 2

@marcofugaro
Copy link
Contributor

Could you try calling

qunit -f !-webonly ./unit/three.source.unit.js

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 4, 2022

I get the same error as before.

It seems other devs have seen this error before but could solve it by simply upgrading node. However, we already use equal or higher node versions. https://stackoverflow.com/questions/69665780/error-err-unsupported-esm-url-scheme-only-file-and-data-urls-are-supported-by

@marcofugaro
Copy link
Contributor

Hmmm if upgrading node to latest doesn't solve it, this is an issue with the qunit code then: qunitjs/qunit#1667

@jancassio
Copy link
Contributor

I have the same issue in a M1 macOS Monterey machine.

In order to fix that, I had to update QUnit at package.json and test/package.json to the version 2.18.2 (latest so far) , then perform npm install at test folder.

@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 28, 2022

Shouldn't you automatically get 2.18.2 because of the^ qualifier in package.json when installing the package?

@marcofugaro
Copy link
Contributor

@Mugen87 there is the package-lock.json, it's taking the 2.18.0 version

"node_modules/qunit": {
"version": "2.18.0",
"resolved": "https://registry.npmjs.org/qunit/-/qunit-2.18.0.tgz",

@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 28, 2022

But what about this line?

"qunit": "^2.18.0",

Or has the entry in the lock file a higher priority?

@jancassio
Copy link
Contributor

I don't think the QUnit version is the problem. I did some tests to investigate it better.

Before figured out the real problem, I just installed qunit at root level package.json. It fixes the issue partially because the test sub module (sub module here means sub folders that hosts package.json inside) requires more dependencies to install.

So, to fix the problem, I had to run npm install at test folder.

This information is missing at CONTRIBUTING.md. And, is also possible to automate the installation process to install dependencies at all sub modules.

The first one is the easy clean and the second one would be an automated solution but add more installing time as tradeoff.

I can do both and send a PR, just let me know what option here fits better.

@LeviPesin
Copy link
Contributor

It is written in https://github.com/mrdoob/three.js/blob/dev/test/README.md. I think it should be added to CONTRIBUTING.md but not be performed automatically...

@marcofugaro
Copy link
Contributor

Or has the entry in the lock file a higher priority?

Yup, since the package-lock.json was introduced all package versions are locked so it's the same on any machine 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants