I have created the following batch that is supposed to run multiple jest tests:
#!/bin/bash
echo 'The test will run 10 times per loop. The number of loops are 20.'
echo 'Total number of instances that will be run: 200 instances'
echo 'Starting in 5 seconds...'
sleep 5
for i in {1..20}; do ${1} & ${1} & ${1} & ${1} & ${1} & ${1} & ${1} & ${1} & ${1} & ${1} || (echo 'Failed after $i attempts' && break); done
The ideia is that once I pass the test as a param, it will run like this: npm run test SomeTest.test.ts & npm run test SomeTest.test.ts & npm run test SomeTest.test.ts.
With this I will be running the same test at the same time, without having to wait for it to be completed.
And I have added it to my package.json like this:
"scripts": {
"stress-test": "./scripts/bash.sh"
}
The idea is to run like this because I want to run only one test from my .test file that has multiple tests npm run test MyJestTest.test.ts -- -t 'some specific test'
. And this command works like a charm when used on the terminal without the bash. But if I try to use it with the bash, it won't work.
npm run stress-test -- "npm run test NelnetService.test.ts -- -t 'loan transactions gets loan transactions data'"
For some reason it won't accept the -t
parameters that I'm adding.
The main idea is to execute a specific test multiple times concurrently through a loop.
Can anyone help me?
&&
not&
for separating your multiple tests