NodeJS
Dependencies
- Ubuntu / Debian
- Arch
- macOS
- Windows
sudo apt install nodejs
sudo pacman -S nodejs
brew install nodejs
choco install nodejs
Initialize a Project
Enable CI Repository Access
To use CI Fuzz and its dependencies you have to configure access to the CI repository. Your private token is available on your CI Download Portal Configuration page.
Add the following repository settings to your global ~/.npmrc
:
~/.npmrc
//gitlab.code-intelligence.com/api/v4/projects/89/packages/npm/:_authToken="<YOUR_TOKEN>"
To use the CI repository in your project, add it to the projects .npmrc
:
.npmrc
@jazzer.js:registry=https://gitlab.code-intelligence.com/api/v4/projects/89/packages/npm/
Enable Fuzz Testing
To enable fuzz testing in your project, add a dev-dependency to @jazzer.js/jest-runner
to your project. To do so, execute the following command:
- Javascript
- Typescript
- npm
- yarn
npm install --save-dev @jazzer.js/jest-runner@3.1.0
yarn add --dev @jazzer.js/jest-runner@3.1.0
- npm
- yarn
npm install --save-dev @jazzer.js/jest-runner@3.1.0 ts-jest ts-node
yarn add --dev @jazzer.js/jest-runner@3.1.0 ts-jest ts-node
Integrate with Jest
To integrate CI Fuzz with your existing Jest setup, add the following code to your projects config file:
- Javascript
- Typescript
jest.config.js
module.exports = {
projects: [
{
displayName: "test",
},
{
testRunner: "@jazzer.js/jest-runner",
displayName: {
name: "Jazzer.js",
color: "cyan",
},
testMatch: ["<rootDir>/**/*.fuzz.js"],
},
],
};
jest.config.ts
import type { Config } from "jest";
const config: Config = {
verbose: true,
projects: [
{
displayName: "Jest",
preset: "ts-jest",
},
{
displayName: {
name: "Jazzer.js",
color: "cyan",
},
preset: "ts-jest",
testRunner: "@jazzer.js/jest-runner",
testEnvironment: "node",
testMatch: ["<rootDir>/*.fuzz.[jt]s"],
},
],
coveragePathIgnorePatterns: ["/node_modules/", "/dist/"],
modulePathIgnorePatterns: ["/node_modules", "/dist/"],
};
export default config;
To introduce the fuzz function types globally, add the following import to the globals.d.ts
or in the individual test
files:
globals.d.ts
import "@jazzer.js/jest-runner";