@flowcore/testing-nestjs-clerk-guard
v1.0.0
Published
Testing library plugin for the @jbiskur/nestjs-test-utitlities package to facilitate easier testing with clerk guards
Downloads
3
Readme
Testing NestJS Clerk Guard
A NestJS ClerkGuard plugin for the @jbiskur/nestjs-test-utilities testing library. To facilitate mocking successful calls to protected routes during testing.
Installation
install with npm:
npm install @flowcore/testing-nestjs-clerk-guard @flowcore/nestjs-clerk-guard
or yarn:
yarn add @flowcore/testing-nestjs-clerk-guard @flowcore/nestjs-clerk-guard
Usage
To use the library with the @jbiskur/nestjs-test-utilities
testing library, you need to invoke it using with
:
import {ClerkGuardModulePlugin} from '@flowcore/testing-nestjs-clerk-guard';
app = await new NestApplicationBuilder()
.withTestModule((testModule) => testModule.withModule(TestModule))
// ... other plugins
.with(ClerkGuardModulePlugin)
// ... other plugins
.build();
It is possible to set the authenticated payload that will be returned by the AuthGuard
:
import {ClerkGuardModulePlugin} from '@flowcore/testing-nestjs-clerk-guard';
app = await new NestApplicationBuilder()
.withTestModule((testModule) => testModule.withModule(TestModule))
// ... other plugins
.with(ClerkGuardModulePlugin, pluginBuilder => pluginBuilder.usingAuthenticatedPayload(validTokenPayload))
.build();
Development
yarn install
or with npm:
npm install