[Bug]: ESbuild fails to install and extension fails to extract tests
Closed this issue · 5 comments
Checklist
- I have read and agree to the Code of Conduct
- I have searched for related issues and discussions but they did not match this problem.
- I want to contribute a bugfix myself.
Actual behavior
Extension fails to install esbuild but continues, then finds test files but logs as error when trying to extract tests. No tests are able to run.
Expected behavior
Tests are found and are able to be run.
Minimal, Reproducible Example
Reproducible using the mocha-vscode-extension
branch for my project:
- Clone repo and checkout branch
- (Optionally) open in devcontainer for best reproducibility
- Enable extension
- Observe extension output with Debug log level
Output
Output from the extension in the devcontainer. The same output is created when running locally on my host machine just with different npm version and parent paths.
2024-09-30 15:55:20.228 [info] Mocha Test Runner Started (id: coderline.mocha-vscode, version 1.2.0) {"version":"v1.2.0+bf265fd","date":"2024-09-13T08:27:14.156Z"}
2024-09-30 15:55:20.228 [debug] Installing ESBuild binary
2024-09-30 15:55:20.228 [debug] Resolving Node.js executable
2024-09-30 15:55:20.228 [debug] Found Node.js in PATH at '/usr/local/share/nvm/current/bin/node'
2024-09-30 15:55:20.228 [debug] [ESBuild-stderr] [esbuild] Failed to find package "@esbuild/linux-x64" on the file system
2024-09-30 15:55:20.228 [debug] [ESBuild-stderr]
2024-09-30 15:55:20.228 [debug] [ESBuild-stderr] This can happen if you use the "--no-optional" flag. The "optionalDependencies"
2024-09-30 15:55:20.228 [debug] [ESBuild-stderr] package.json feature is used by esbuild to install the correct binary executable
2024-09-30 15:55:20.228 [debug] [ESBuild-stderr] for your current platform. This install script will now attempt to work around
2024-09-30 15:55:20.228 [debug] [ESBuild-stderr] this. If that fails, you need to remove the "--no-optional" flag to use esbuild.
2024-09-30 15:55:20.228 [debug] [ESBuild-stderr]
2024-09-30 15:55:20.228 [debug] [ESBuild-stderr] [esbuild] Trying to install package "@esbuild/linux-x64" using npm
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] node:internal/errors:865
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] const err = new Error(message);
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] ^
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr]
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] Error: Command failed: /usr/local/share/nvm/versions/node/v18.19.1/bin/node /home/node/.vscode-server/extensions/coderline.mocha-vscode-1.2.0/node_modules/esbuild/bin/esbuild --version
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] node:internal/modules/cjs/loader:1137
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] throw err;
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] ^
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr]
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] Error: Cannot find module '/home/node/.vscode-server/extensions/coderline.mocha-vscode-1.2.0/node_modules/esbuild/bin/esbuild'
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] at Module._load (node:internal/modules/cjs/loader:975:27)
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] at node:internal/main/run_main_module:28:49 {
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] code: 'MODULE_NOT_FOUND',
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] requireStack: []
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] }
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr]
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] Node.js v18.19.1
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr]
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] at checkExecSyncError (node:child_process:890:11)
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] at Object.execFileSync (node:child_process:926:15)
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] at validateBinaryVersion (/home/node/.vscode-server/extensions/coderline.mocha-vscode-1.2.0/node_modules/esbuild/install.js:100:28)
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] at /home/node/.vscode-server/extensions/coderline.mocha-vscode-1.2.0/node_modules/esbuild/install.js:282:5
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] status: 1,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] signal: null,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] output: [
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] null,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] Buffer(0) [Uint8Array] [],
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] Buffer(527) [Uint8Array] [
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 110, 111, 100, 101, 58, 105, 110, 116, 101, 114, 110, 97,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 108, 47, 109, 111, 100, 117, 108, 101, 115, 47, 99, 106,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 115, 47, 108, 111, 97, 100, 101, 114, 58, 49, 49, 51,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 55, 10, 32, 32, 116, 104, 114, 111, 119, 32, 101, 114,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 114, 59, 10, 32, 32, 94, 10, 10, 69, 114, 114, 111,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 114, 58, 32, 67, 97, 110, 110, 111, 116, 32, 102, 105,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 110, 100, 32, 109, 111, 100, 117, 108, 101, 32, 39, 47,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 104, 111, 109, 101, 47, 110, 111, 100, 101, 47, 46, 118,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 115, 99, 111, 100,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] ... 427 more items
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] ]
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] ],
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] pid: 743,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] stdout: Buffer(0) [Uint8Array] [],
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] stderr: Buffer(527) [Uint8Array] [
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 110, 111, 100, 101, 58, 105, 110, 116, 101, 114, 110, 97,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 108, 47, 109, 111, 100, 117, 108, 101, 115, 47, 99, 106,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 115, 47, 108, 111, 97, 100, 101, 114, 58, 49, 49, 51,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 55, 10, 32, 32, 116, 104, 114, 111, 119, 32, 101, 114,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 114, 59, 10, 32, 32, 94, 10, 10, 69, 114, 114, 111,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 114, 58, 32, 67, 97, 110, 110, 111, 116, 32, 102, 105,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 110, 100, 32, 109, 111, 100, 117, 108, 101, 32, 39, 47,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 104, 111, 109, 101, 47, 110, 111, 100, 101, 47, 46, 118,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] 115, 99, 111, 100,
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] ... 427 more items
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] ]
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] }
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr]
2024-09-30 15:55:20.656 [debug] [ESBuild-stderr] Node.js v18.19.1
2024-09-30 15:55:20.659 [error] Installing ESBuild binary exited with code 1
2024-09-30 15:55:20.659 [debug] Syncing workspace folders 0
2024-09-30 15:55:20.659 [debug] New workspace folder {"uri":{"$mid":1,"fsPath":"/workspaces/multi-scrobbler","external":"file:///workspaces/multi-scrobbler","path":"/workspaces/multi-scrobbler","scheme":"file"},"name":"multi-scrobbler","index":0}
2024-09-30 15:55:20.754 [debug] Checking workspace folder for config files {"uri":{"$mid":1,"fsPath":"/workspaces/multi-scrobbler","external":"file:///workspaces/multi-scrobbler","path":"/workspaces/multi-scrobbler","scheme":"file"},"name":"multi-scrobbler","index":0}
2024-09-30 15:55:20.754 [debug] Added new controller via config file file:///workspaces/multi-scrobbler/.mocharc.json
2024-09-30 15:55:20.754 [info] New Test Controller for workspace folder and config /workspaces/multi-scrobbler /workspaces/multi-scrobbler/.mocharc.json
2024-09-30 15:55:20.754 [debug] resolving 'mocha/lib/cli/options' via /workspaces/multi-scrobbler
2024-09-30 15:55:20.754 [debug] Creating new resolver for resolving Mocha
2024-09-30 15:55:20.757 [debug] 'mocha/lib/cli/options' resolved to '/workspaces/multi-scrobbler/node_modules/mocha/lib/cli/options.js'
2024-09-30 15:55:20.798 [debug] resolving 'mocha/lib/cli/config' via /workspaces/multi-scrobbler
2024-09-30 15:55:20.798 [debug] 'mocha/lib/cli/config' resolved to '/workspaces/multi-scrobbler/node_modules/mocha/lib/cli/config.js'
2024-09-30 15:55:20.802 [debug] Reading mocharc, changing working directory to /workspaces/multi-scrobbler
2024-09-30 15:55:20.802 [debug] Loaded mocharc via Mocha
2024-09-30 15:55:20.802 [debug] Reading mocharc, changing working directory back to /vscode/vscode-server/bin/linux-x64/4849ca9bdf9666755eb463db297b69e5385090e3
2024-09-30 15:55:20.802 [debug] Loaded mocharc via '/workspaces/multi-scrobbler/.mocharc.json', with patterns [{"glob":true,"value":"/workspaces/multi-scrobbler/src/backend/tests/**/*.test.ts","workspaceFolderRelativeGlob":"src/backend/tests/**/*.test.ts"}]
2024-09-30 15:55:20.897 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/component/component.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/component/component.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/component/component.test.ts","scheme":"file"}
2024-09-30 15:55:20.897 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/scrobbler/scrobblers.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/scrobbler/scrobblers.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/scrobbler/scrobblers.test.ts","scheme":"file"}
2024-09-30 15:55:20.897 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/player/player.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/player/player.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/player/player.test.ts","scheme":"file"}
2024-09-30 15:55:20.897 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/source/source.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/source/source.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/source/source.test.ts","scheme":"file"}
2024-09-30 15:55:20.897 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/utils/playComparisons.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/utils/playComparisons.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/utils/playComparisons.test.ts","scheme":"file"}
2024-09-30 15:55:20.897 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/listenbrainz/listenbrainz.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/listenbrainz/listenbrainz.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/listenbrainz/listenbrainz.test.ts","scheme":"file"}
2024-09-30 15:55:20.897 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/utils/strings.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/utils/strings.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/utils/strings.test.ts","scheme":"file"}
2024-09-30 15:55:20.897 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/jellyfin/jellyfin.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/jellyfin/jellyfin.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/jellyfin/jellyfin.test.ts","scheme":"file"}
2024-09-30 15:55:20.918 [error] Error while test extracting {}
2024-09-30 15:55:20.923 [error] Error while test extracting {}
2024-09-30 15:55:20.923 [info] No tests found in '/workspaces/multi-scrobbler/src/backend/tests/listenbrainz/listenbrainz.test.ts'
2024-09-30 15:55:20.923 [info] No tests found in '/workspaces/multi-scrobbler/src/backend/tests/utils/playComparisons.test.ts'
2024-09-30 15:55:20.923 [info] No tests found in '/workspaces/multi-scrobbler/src/backend/tests/player/player.test.ts'
2024-09-30 15:55:20.925 [info] No tests found in '/workspaces/multi-scrobbler/src/backend/tests/jellyfin/jellyfin.test.ts'
2024-09-30 15:55:20.925 [info] No tests found in '/workspaces/multi-scrobbler/src/backend/tests/utils/strings.test.ts'
2024-09-30 15:55:20.927 [error] Error while test extracting {}
Plugin Version Details
Name: Mocha for VS Code
Id: coderline.mocha-vscode
Description: Run and debug Mocha tests right within VS Code.
Version: 1.2.0
Publisher: CoderLine
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=coderline.mocha-vscode
VS Code Version Details
Version: 1.93.0
Commit: 4849ca9bdf9666755eb463db297b69e5385090e3
Date: 2024-09-04T13:02:38.431Z
Electron: 30.4.0
ElectronBuildId: 10073054
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Linux x64 6.10.9-arch1-2
Further details
On the host machine the extension is using node 22.8.0 found at /usr/bin/node
but I use nvm
and node 18.19.1 (specified in launch/settings.json). This shouldn't be a problem though since the same behavior occurs in the devcontainer when using the same node version and an official devcontainer image.
You can see the mocharc file in the repo but for brevity:
{
"reporter": "dot",
"extension": "ts",
"import": "tsx/esm",
"spec": "./src/backend/tests/**/*.test.ts"
}
I use tsx
for running the application and running mocha tests npm run test
without issue. Webstorm also has no issue parsing tests from mocha.
I had the same problem. It looks like optional dependencies (@esbuild/linux-x64
in this case) are not being installed when the extension is initially installed via VSCode. Not sure if something has changed there.
I got this extension to install properly & work by running npm i
inside the extension folder itself after install. In the OP's case that would be in /home/node/.vscode-server/extensions/coderline.mocha-vscode-1.2.0
. npm i
complained about not being able to "cd to src/typings", but I ignored that and it still worked.
Finally it requires a reload of the VSCode window to reactivate the extension.
Hope this helps.
Edit:
VSCode details
Version: 1.94.0 (user setup)
Commit: d78a74bcdfad14d5d3b1b782f87255d802b57511
Date: 2024-10-02T13:08:12.626Z
Electron: 30.5.1
ElectronBuildId: 10262041
Chromium: 124.0.6367.243
Node.js: 20.16.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22635
running in WSL with Ubuntu-20.04.
When the Extension launches it will install the dependencies according to the platform. This is what we see in the logs.
Lines 140 to 177 in 2815fa5
From the logs I see the esbuild script attempts to install the package but then doesn't really report it being installed. esbuild does this npm installation here: https://github.com/evanw/esbuild/blob/d34e79e2a998c21bb71d57b92b0017ca11756912/lib/npm/node-install.ts#L118
I will need to try setting up a similar setup to troubleshoot. In the meanwhile you could try following to see if there are suspicious logs which help finding the problem:
- Go to the Extension install directory (e.g.
/home/node/.vscode-server/extensions/coderline.mocha-vscode-1.2.0/
as printed in the logs) - Try running the esbuild install script. Maybe there are some logs hidden and not forwarded by this extension:
cd /home/node/.vscode-server/extensions/coderline.mocha-vscode-1.2.0/node_modules/esbuild
/usr/local/share/nvm/current/bin/node install.js
- Try installing the optional dependency manually. I'd expect some sort of info or error output.
cd /home/node/.vscode-server/extensions/coderline.mocha-vscode-1.2.0/
npm install --prefer-offline --no-audit @esbuild/linux-x64@0.24.0
Running the esbuild script (2) produces the same output as from my OP ([esbuild] Failed to find package "@esbuild/linux-x64" on the file system
) without any additional logging that would be helpful.
I was able to install it successfully using (3) at which point (2) causes no errors to output.
Using the extension at this point does not spit out the same errors but tests are still unable to be extracted:
2024-10-08 17:24:00.883 [info] Mocha Test Runner Started (id: coderline.mocha-vscode, version 1.2.0) {"version":"v1.2.0+bf265fd","date":"2024-09-13T08:27:14.156Z"}
2024-10-08 17:24:00.883 [debug] Installing ESBuild binary
2024-10-08 17:24:00.883 [debug] Resolving Node.js executable
2024-10-08 17:24:00.883 [debug] Found Node.js in PATH at '/usr/local/bin/node'
2024-10-08 17:24:00.909 [debug] Installing ESBuild binary exited with code 0
2024-10-08 17:24:00.909 [debug] Syncing workspace folders 0
2024-10-08 17:24:00.909 [debug] New workspace folder {"uri":{"$mid":1,"fsPath":"/workspaces/multi-scrobbler","external":"file:///workspaces/multi-scrobbler","path":"/workspaces/multi-scrobbler","scheme":"file"},"name":"multi-scrobbler","index":0}
2024-10-08 17:24:01.005 [debug] Checking workspace folder for config files {"uri":{"$mid":1,"fsPath":"/workspaces/multi-scrobbler","external":"file:///workspaces/multi-scrobbler","path":"/workspaces/multi-scrobbler","scheme":"file"},"name":"multi-scrobbler","index":0}
2024-10-08 17:24:01.005 [debug] Added new controller via config file file:///workspaces/multi-scrobbler/.mocharc.json
2024-10-08 17:24:01.005 [info] New Test Controller for workspace folder and config /workspaces/multi-scrobbler /workspaces/multi-scrobbler/.mocharc.json
2024-10-08 17:24:01.005 [debug] resolving 'mocha/lib/cli/options' via /workspaces/multi-scrobbler
2024-10-08 17:24:01.005 [debug] Creating new resolver for resolving Mocha
2024-10-08 17:24:01.033 [debug] 'mocha/lib/cli/options' resolved to '/workspaces/multi-scrobbler/node_modules/mocha/lib/cli/options.js'
2024-10-08 17:24:01.076 [debug] resolving 'mocha/lib/cli/config' via /workspaces/multi-scrobbler
2024-10-08 17:24:01.091 [debug] 'mocha/lib/cli/config' resolved to '/workspaces/multi-scrobbler/node_modules/mocha/lib/cli/config.js'
2024-10-08 17:24:01.095 [debug] Reading mocharc, changing working directory to /workspaces/multi-scrobbler
2024-10-08 17:24:01.095 [debug] Loaded mocharc via Mocha
2024-10-08 17:24:01.095 [debug] Reading mocharc, changing working directory back to /vscode/vscode-server/bin/linux-x64/4849ca9bdf9666755eb463db297b69e5385090e3
2024-10-08 17:24:01.095 [debug] Loaded mocharc via '/workspaces/multi-scrobbler/.mocharc.json', with patterns [{"glob":true,"value":"/workspaces/multi-scrobbler/src/backend/tests/**/*.test.ts","workspaceFolderRelativeGlob":"src/backend/tests/**/*.test.ts"}]
2024-10-08 17:24:01.097 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/.git/FETCH_HEAD","path":"/workspaces/multi-scrobbler/.git/FETCH_HEAD","scheme":"file"}
2024-10-08 17:24:01.207 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/player/player.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/player/player.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/player/player.test.ts","scheme":"file"}
2024-10-08 17:24:01.207 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/source/source.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/source/source.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/source/source.test.ts","scheme":"file"}
2024-10-08 17:24:01.207 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/component/component.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/component/component.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/component/component.test.ts","scheme":"file"}
2024-10-08 17:24:01.207 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/listenbrainz/listenbrainz.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/listenbrainz/listenbrainz.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/listenbrainz/listenbrainz.test.ts","scheme":"file"}
2024-10-08 17:24:01.207 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/jellyfin/jellyfin.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/jellyfin/jellyfin.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/jellyfin/jellyfin.test.ts","scheme":"file"}
2024-10-08 17:24:01.207 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/utils/playComparisons.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/utils/playComparisons.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/utils/playComparisons.test.ts","scheme":"file"}
2024-10-08 17:24:01.207 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/utils/strings.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/utils/strings.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/utils/strings.test.ts","scheme":"file"}
2024-10-08 17:24:01.207 [debug] Syncing file {"$mid":1,"fsPath":"/workspaces/multi-scrobbler/src/backend/tests/scrobbler/scrobblers.test.ts","external":"file:///workspaces/multi-scrobbler/src/backend/tests/scrobbler/scrobblers.test.ts","path":"/workspaces/multi-scrobbler/src/backend/tests/scrobbler/scrobblers.test.ts","scheme":"file"}
2024-10-08 17:24:01.224 [info] No tests found in '/workspaces/multi-scrobbler/src/backend/tests/listenbrainz/listenbrainz.test.ts'
2024-10-08 17:24:01.233 [error] Error while test extracting {}
2024-10-08 17:24:01.233 [info] No tests found in '/workspaces/multi-scrobbler/src/backend/tests/player/player.test.ts'
2024-10-08 17:24:01.233 [info] No tests found in '/workspaces/multi-scrobbler/src/backend/tests/jellyfin/jellyfin.test.ts'
2024-10-08 17:24:01.233 [info] No tests found in '/workspaces/multi-scrobbler/src/backend/tests/utils/playComparisons.test.ts'
2024-10-08 17:24:01.235 [error] Error while test extracting {}
2024-10-08 17:24:01.235 [info] No tests found in '/workspaces/multi-scrobbler/src/backend/tests/utils/strings.test.ts'
2024-10-08 17:24:01.237 [error] Error while test extracting {}
Specifically, I see TypeError: Cannot read properties of undefined (reading 'use')
below the test files
EDIT:
I switched to using mcr.microsoft.com/devcontainers/javascript-node:1-18-bookworm
so that NVM is no longer used in the container:
2024-10-08 17:39:12.742 [debug] Found Node.js in PATH at '/usr/local/bin/node'
Same results though.
Seems the install.js of ESBuild is rather broken. It attempts to download and install the platform specific dependency, but the paths where they are then placed are wrong leading to execution errors.
The "extraction" error is rather a code execution problem in multi-scrobbler. mocha-vscode attempts to mock all imports to the project and then fake-execute the test file to discover the tests contained.
In multi-scrobbler the code above the actual tests leads to an error: chai.use
. The problems are on multiple levels:
- In the import
import chai, { assert, expect} from 'chai'
thechai
import is undefined. - Changing it to the following code still shows
chai
as undefined.
import chai from 'chai';
chai.use(asPromised);
const assert = chai.assert;
const expect = chai.expect;
- Changing it to the following code complains that
use
is not a function as we mock things to objects.
import * as chai from 'chai';
chai.use(asPromised);
const assert = chai.assert;
const expect = chai.expect;
To fix these problems we need two fixes:
- Default imports need mocking.
- We need to extend the
Proxy
to be callable. Theapply
trap should work.
@FoxxMD I released a 1.2.1 patch with all improvements. Can you give them a try in your setup (once the update becomes available)? IN my test setup things worked as expected.
If you have more advanced logic across imports which actually need execution of the files including their dependencies, you could switch your project settings to evaluation-cjs-full
. This way no "mocking" of the imports happen (at the cost of performance).