I can run jest tests fine via a .njsproj but with a .csproj project and a node_modules located at \ClientApp vstest.console.exe does not find the packages needed.
https://stackoverflow.com/a/64064559/3850405
Failed to find "jest" package. "jest" must be installed in the project locally. Install "jest" locally using the npm manager via solution explorer or with ".npm install jest --save-dev" via the Node.js interactive window. Failed to find "jest-editor-support" package. "jest-editor-support" must be installed in the project locally. Install "jest-editor-support" locally using the npm manager via solution explorer or with ".npm install jest-editor-support --save-dev" via the Node.js interactive window.
Command:
vstest.console.exe "C:\Users\Oscar\source\repos\WebApplication1\WebApplication1\WebApplication1.csproj" "/TestAdapterPath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\Microsoft\NodeJsTools\TestAdapter"
Is there some way to specify the location of either package.json or the node_modules folder? The project is using .NET Core 3.1.
I have followed this guide:
Added the following values to PropertyGroup in .csproj:
<JavaScriptTestFramework>Jest</JavaScriptTestFramework>
<JavaScriptTestRoot>ClientApp\src\tests\</JavaScriptTestRoot>
<GenerateProgramFile>false</GenerateProgramFile>
<SpaRoot>ClientApp\</SpaRoot>
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
Tested both with and without SpaRoot and DefaultItemExcludes.
I have not specified outdir or outfile option in tsconfig.json and I have installed the NuGet Microsoft.JavaScript.UnitTest.
Working test from .njsproj after jest and jest-editor-support was installed.
