vscode-jest-runner icon indicating copy to clipboard operation
vscode-jest-runner copied to clipboard

Usage Error: Couldn't find a script named "jest"

Open the21st opened this issue 3 years ago • 4 comments

I'm in a Yarn2 PnP monorepo, where jest is installed in some of the modules' package.json but not at the root package.json. I tried running a test which was correctly highlighted by CodeLens but I received the following message in the terminal:

Usage Error: Couldn't find a script named "jest".

Repo structure is like this:

    package.json (containing workspaces definition)
    module1
        package.json (containing own module dependencies)
        tsconfig.json
        jest.config.ts
    module2
        package.json (containing own module dependencies)
        tsconfig.json
        jest.config.js

module2 is using a different build system than module1 so I cannot have a common jest.config for the two

the21st avatar Jan 12 '22 11:01 the21st

Have you checked the add-on settings options for PNP?

Regards Tristan

Simon Sotak @.***> schrieb am Mi., 12. Jan. 2022, 11:31:

I'm in a Yarn2 PnP monorepo, where jest is installed in some of the workspaces' package.json but not at the root package.json. I tried running a test which was correctly highlighted by CodeLens but I received the following message in the terminal:

Usage Error: Couldn't find a script named "jest".

— Reply to this email directly, view it on GitHub https://github.com/firsttris/vscode-jest-runner/issues/230, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANBJTDRKAS5XNUBLKGEKSLUVVRCTANCNFSM5LYXOEPA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

firsttris avatar Jan 12 '22 15:01 firsttris

@firsttris Yes, it's enabled:

image

the21st avatar Jan 15 '22 11:01 the21st

I think problem here is that you have no jest in your root package.json, though even if you add it there this might still not work correctly since it will try to load jest config from root as well. Perhaps this plugin needs proper support for yarn workspaces, to work with monorepos.

Othreumaru avatar Jan 27 '22 00:01 Othreumaru

check 0.4.48 and report if this issue still persists.

firsttris avatar Mar 09 '22 08:03 firsttris