运行 只有一个带有 NX 的 Jest 测试文件

Run only one Jest test file with NX

nx run myproject:test --testFile=libs/myproject/src/lib/guards/role.guard.spec.ts

我希望只测试一个 .spec 文件。但是,错误输出显示了额外的 .spec 文件。

$ nx run myproject:test --testFile=libs/myproject/src/lib/guards/role.guard.spec.ts 

FAIL   core  libs/myproject/src/lib/guards/role.guard.spec.ts
● Test suite failed to run

    libs/myproject/src/lib/auth/auth.service.ts:49:11 - error TS2564: Property 'sessions' has...

    49   private sessions: string;
    libs/myproject/src/lib/auth/auth.service.ts:51:11 - error TS2564...

... Many more lines ...

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        6.953 s
Ran all test suites matching /libs\myproject\src\lib\guards\role.guard.spec.ts/i.

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

我发帖时必须有 mis-read 输出。看起来我发布的 nx jest 命令确实有效。