Skip to main content

Installation

Install Behavioral with dependencies all at once with following command:

npm install --save-dev reflect-metadata jest typescript ts-jest @types/jest @typedtools/behavioral @typedtools/behavioral-jest

Configure typescript

Behavioral uses decorators which are not turned on by default. Update your tsconfig.json file with the following options:

"experimentalDecorators": true,
"emitDecoratorMetadata": true,

Configure jest

Behavioral requires typescript which is not available in Jest by default. To add support for typescript configure ts-jest with the following command:

npx ts-jest config:init

This command will create jest.config.js in project root directory. Needs to be updated about setup file with following content:

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ["**/*.feature", "**/*.{spec,test}.{ts,js}"],
moduleFileExtensions: ['feature', 'js', 'mjs', 'ts'],
transform: {
"\.feature$": "@typedtools/behavioral-jest"
},
setupFilesAfterEnv: ['<rootDir>/setup.ts'],
};

And that's it you are ready to go ๐Ÿ˜„