Lewis Munene
Lewis Munene

Reputation: 164

How to set up CodeceptJS in a monorepo

I am using a pnpm workspace with different packages to distinguish the modules. I intend to use CodeceptJS as my test automation framework but whenever I install and initialize CodeceptJS in the root directory (pnpm add -w codeceptjs playwright then pnpm dlx codeceptjs init), it is not recognized within the individual packages.

If I do pnpm dlx codeceptjs init within a package, it gives this warning: "WARNING: CodeceptJS is not installed locally. It is recommended to switch to local installation" and then installs CodeceptJS in that package. Is it possible to have one shared instance of CodeceptJS with Playwright for a monorepo setup as opposed to installing it one-by-one in all packages?

Here is my directory structure:

root
├──node_modules
│  
├──packages
│  ├──package1
│  │   ├──node_modules
│  │   └──package.json
│  └──package2
│     ├──node_modules
│     └──package.json
|  
└──package.json

Upvotes: 1

Views: 212

Answers (1)

Zoltan Kochan
Zoltan Kochan

Reputation: 7686

In order to run the locally installed instance of codeceptjs, you need to run one of these commands:

pnpm exec codeceptjs init

or

pnpm codeceptjs init

pnpm dlx downloads the package and executes it.

Unlike npx, which is checking if a package exists locally and runs it or installs it in a hidden location, pnpm has two separate commands. One for just running a local package (pnpm exec) and another one for downloading and running.

Upvotes: 1

Related Questions