hbenl / vscode-jasmine-test-adapter

Jasmine Test Adapter for the VS Code Test Explorer
MIT License
20 stars 20 forks source link

TypeError when running tests from Array.forEach #60

Closed reinholdk closed 2 years ago

reinholdk commented 2 years ago

After updating the extension from version 1.7.1 test explorer is no longer loading due to the following exception. I'm dynamically creating describe() calls in a forEach loop. The problem seems to be caused by patchJasmine.js looping over the stack trace and the stack frame for the built-in Array.forEach has not source file (null) attached:

TypeError: Cannot read properties of null (reading 'split')
    at Minimatch.match (/Users/xxx/.vscode/extensions/hbenl.vscode-jasmine-test-adapter-1.8.1/node_modules/minimatch/minimatch.js:859:11)
    at /Users/xxx/.vscode/extensions/hbenl.vscode-jasmine-test-adapter-1.8.1/out/worker/patchJasmine.js:29:29
    at Array.some (<anonymous>)
    at findCallLocation (/Users/xxx/.vscode/extensions/hbenl.vscode-jasmine-test-adapter-1.8.1/out/worker/patchJasmine.js:27:19)
    at Env.env.<computed> [as describe] (/Users/xxx/.vscode/extensions/hbenl.vscode-jasmine-test-adapter-1.8.1/out/worker/patchJasmine.js:14:30)
    at describe (/Users/xxx/git/my-project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8345:18)
    at runTestCases (file:///Users/xxx/git/my-project/test/xyz/testUtil.js:92:5)
    at file:///Users/xxx/git/my-project/test/all.spec.js:122:5
    at Array.forEach (<anonymous>)
    at file:///Users/xxx/git/my-project/test/all.spec.js:121:7
apla commented 2 years ago

I faced the same issue when using Jasmine 4 and ESM.

The Jasmine test loader worker process finished with code 1 and signal null.
/code/vscode-jasmine-test-adapter/node_modules/minimatch/minimatch.js:861
    f = f.split(slashSplit)
          ^

TypeError: Cannot read properties of null (reading 'split')
    at Minimatch.match (/code/vscode-jasmine-test-adapter/node_modules/minimatch/minimatch.js:861:11)
    at /code/vscode-jasmine-test-adapter/out/worker/patchJasmine.js:28:37
    at Array.some (<anonymous>)
    at findCallLocation (/code/vscode-jasmine-test-adapter/out/worker/patchJasmine.js:28:19)
    at env.<computed> [as describe] (/code/vscode-jasmine-test-adapter/out/worker/patchJasmine.js:14:30)
    at describe (/code/funar/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8325:18)
    at file:///code/funar/test/000-single-test.js:5:1
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:409:24)

Internal JS functions with callbacks obviously have no file name.

reinholdk commented 2 years ago

@hbenl thanks for the fix! Could update to v1.8.2 successfully.