使用 NX 仅运行一个 Jest 测试文件

Les*_*sar 7 nomachine-nx jestjs angular

nx run myproject:test --testFile=libs/myproject/src/lib/guards/role.guard.spec.ts\n
Run Code Online (Sandbox Code Playgroud)\n

我预计只测试一个 .spec 文件。但是,错误输出显示其他 .spec 文件。

\n
$ nx run myproject:test --testFile=libs/myproject/src/lib/guards/role.guard.spec.ts \n\nFAIL   core  libs/myproject/src/lib/guards/role.guard.spec.ts\n\xe2\x97\x8f Test suite failed to run\n\n    libs/myproject/src/lib/auth/auth.service.ts:49:11 - error TS2564: Property 'sessions' has...\n\n    49   private sessions: string;\n    libs/myproject/src/lib/auth/auth.service.ts:51:11 - error TS2564...\n\n... Many more lines ...\n\nTest Suites: 1 failed, 1 total\nTests:       0 total\nSnapshots:   0 total\nTime:        6.953 s\nRan all test suites matching /libs\\\\myproject\\\\src\\\\lib\\\\guards\\\\role.guard.spec.ts/i.\n
Run Code Online (Sandbox Code Playgroud)\n

为什么要运行额外的测试,例如libs/myproject/src/lib/auth/secure.directive.spec.ts

\n

Les*_*sar 2

当我发布此内容时,我一定是误读了输出。看起来我发布的 nx jest 命令确实有效。