I'm aware of the VS Code setting named typescript.preferences.autoImportFileExcludePatterns (ref), and my local VS Code is using a recent TypeScript version which support that setting:
Yet I'm not able to prevent VS Code from suggesting to import members from node:test module when writing my test files. For the records I'm using vitest as a test runner, which has typical function names clashing with node:test ones (describe, beforeEach, it).
I tried the following setting, with no luck:
"typescript.preferences.autoImportFileExcludePatterns": ["node:test"],
Of course node-test is not an npm package, so the classic example using "**/node_modules/...some package name..." does not apply here.
Did anyone come into this already?

Update: I was wrong(ish)
It seems you can. For example, to prevent suggestions from things in
node:test, you can exclude the file(s) that define the module"typescript.preferences.autoImportFileExcludePatterns": ["node/test.d.ts"]in a settings.json file (user or workspace, etc.). You were close with trying to usenode:test, buttypescript.preferences.autoImportFileExcludePatternsworks with file paths and not TypeScript module names. The patternnode/test.d.tswill match the file that the@types/nodedefines thenode:testmodule in. Caveat: This may only work nicely if the module is the only module defined in the files that define it. Otherwise, you may exclude modules that are defined in the same files. Though I was quite surprised to see that the file exclusion would work on type definition files that are triple-slash-referenced by an index type definition file.Old (partially wrong) answer
VS Code added a feature to remember suggestion selections (see Remember suggestion selections #22839). You can see the related commit that completed the issue, and this related file. This is to say- if you set the VS Code setting named
editor.suggestSelectionto either"recentlyUsed"or"recentlyUsedByPrefix", I think you could get a nice workaround for what you want by just selecting the suggestion you want a couple times.To get better than that (and actually exclude a specific ambient module declaration from auto import suggestions), I don't think this is easily possible.
node:testis an ambient module declaration innode_modules/@types/node/index.d.ts, which is referenced in.node_modules/@types/node/index.d.tsby a/// <reference path="test.d.ts" />, and that index.d.ts file is made part of module resolution by virtue of being specified in the node module's package.json with"types": "index.d.ts". I'm not aware of a feature to exclude module declarations from auto imports, and you don't want to augment the module- you want to make it as if it didn't exist for IntelliSense purposes.What you could try to do is make your own modified copy of the
@types/nodepackage where you edit that index.d.ts file to remove the line that does/// <reference path="test.d.ts" />.There is a "nuclear" VS Code setting called
typescript.preferences.includePackageJsonAutoImports, which I don't think is what you want- using it to disable thenode:testimport suggestion would also disable the import for the vitest module you want to import.You may also be interested to read