1.0.0 • Published 1 year ago

@flowcore/testing-nestjs-clerk-guard v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Build

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