0

I want the script command below to have something like where it should run tests in that folder name

"scripts": {
    "test": "jest --testPathPattern==tests/<folder-name> --maxWorkers=2"
  },

to run tests in a particular folder.

This command is executed in a bash file run-tests.sh as shown below

#!/bin/bash
npm run test

is it possible to have something like

#!/bin/bash
npm run test <folder-name>  
Shammir
  • 927
  • 4
  • 17
  • 32
  • Does this answer your question? [Sending command line arguments to npm script](https://stackoverflow.com/questions/11580961/sending-command-line-arguments-to-npm-script) – Zak Mar 14 '22 at 21:01

1 Answers1

1

According to the jest documentation you should be able to do this:

npm run test -- --testPathPattern==tests/<folder-name>

source: https://jestjs.io/docs/cli#using-with-npm-scripts

Alternatively something like this in your bash script should do the trick as well:

#!/bin/bash
pushd <directory here> # Basically cd into that directory
npm run test
popd # cd back into where we came from when we ran pushd

I think this will do what you are asking.

Veda
  • 2,025
  • 1
  • 18
  • 34