Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions bin/nocha.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

usage() {
echo "Usage: $0 [options] [file/files/pattern]"
echo ""
echo "This script runs Node.js tests with specified options."
echo ""
echo "Options:"
echo " --help"
echo " Display this help message."
echo " --import <path>"
echo " Import a module before running tests. eg: --import ./test/helpers/setup.js"
echo " --experimental-test-coverage"
echo " Enable experimental test coverage."
echo " --experimental-test-isolation=mode"
echo " Set the test isolation mode."
echo " --experimental-test-module-mocks"
echo " Enable experimental test module mocks."
echo " --test-concurrency <number|boolean>"
echo " Set the concurrency level for tests."
echo " If a number is provided, that many test processes run in parallel."
echo " If true, runs os.availableParallelism() - 1 test files in parallel."
echo " If false, runs one test file at a time. Default: false."
echo " --test-coverage-branches=threshold"
echo " Set the branch coverage threshold."
echo " --test-coverage-exclude"
echo " Exclude files from coverage."
echo " --test-coverage-functions=threshold"
echo " Set the function coverage threshold."
echo " --test-coverage-include"
echo " Include files for coverage."
echo " --test-coverage-lines=threshold"
echo " Set the line coverage threshold."
echo " --test-force-exit"
echo " Force exit after tests complete even if the event loop remains active."
echo " --test-name-pattern"
echo " Run tests matching the pattern."
echo " --test-only"
echo " Run only the specified tests."
echo " --test-reporter"
echo " Specify the test reporter."
echo " --test-reporter-destination"
echo " Specify the destination for the test report."
echo " --test-shard"
echo " Run a specific shard of tests."
echo " --test-skip-pattern"
echo " Skip tests matching the pattern."
echo " --test-timeout"
echo " Set the test timeout in milliseconds."
echo " --test-update-snapshots"
echo " Update snapshots."
echo ""
echo "Examples:"
echo " $0 --test test/file1.js"
echo " $0 --test --test-reporter spec test/file1.js test/file2.js"
echo " $0 --test --test-timeout 5000 'test/**/*.js'"
echo ""
echo "--test will be added automatically to the node arguments."
echo ""
echo "Run node --help for more options."
exit 1
}

if [[ "$1" == "--help" ]]; then
usage
fi

node --test "$@"
13 changes: 8 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"scripts": {
"test": "node --test"
},
"bin": {
"nocha": "bin/nocha.sh"
},
"repository": {
"type": "git",
"url": "git+https://github.com/BonnierNews/node-test-bdd.git"
Expand Down