Setup japa inside an existing Node.js app
The create-japa
is a CLI utility configuring Japa inside a new or existing Node.js project.
The process involves installing the required packages and creating the necessary files. The setup works with Typescript and JavaScript projects.
Navigate to the root of your project and run the following command.
# npm
npm init japa
# yarn
yarn create japa
# pnpm
pnpm create japa
You can pass the destination directory as the first argument to the command. The process.cwd()
will be used when the option is not defined.
npm init japa my-app
Define the package manager to use to install dependencies. If not defined, we will attempt to detect the package manager using @antfu/install-pkg package.
npm init japa -- --package-manager=pnpm
Define an array of plugins to install. We will display a series of prompts if this flag is not set.
npm init japa -- --plugins="@japa/api-client" --plugins="@japa/snapshot"
Define the project type for which you want to configure Japa. The value could be either typescript
or javascript
. If this flag is not set, we will display a prompt for the project type selection.
npm init japa -- --project-type=typescript
Enable the flag to create a sample test file or disable it not to create it.
# Enable it
npm init japa -- --sample-test-file
# Disable it
npm init japa -- --no-sample-test-file