You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/bin/bash
cp $UPLOADED_FILES/codegrade.test.js .echo'Copied test file'
Script (Install dependencies)
#!/bin/bashexport NVM_DIR="$HOME/.nvm"
[ -s"$NVM_DIR/nvm.sh" ] &&\."$NVM_DIR/nvm.sh"
nvm use --lts
npm i
Connect Rubric
Custom Test
# Write your bash script here, output the score in a JSON object to structured output (file descriptor 3).# For example: echo '{ "tag": "points", "points": "1/3" }' >&3#!/bin/bashexport NVM_DIR="$HOME/.nvm"
[ -s"$NVM_DIR/nvm.sh" ] &&\."$NVM_DIR/nvm.sh"
nvm use --lts
npm run test:codegrade -- codegrade.test.js --json --outputFile=results.json
# Extracting the number of passed and total tests
num_passed_tests=$(jq '.numPassedTests' results.json)
num_total_tests=$(jq '.numTotalTests' results.json)# Calculating the ratioif [ "$num_total_tests"-eq 0 ];thenecho"No tests were found."exit 1
fi
ratio="$num_passed_tests/$num_total_tests"# Output the result in the desired formatecho"{ \"tag\": \"points\", \"points\": \"$ratio\" }">&3