Skip to content
Open
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
61 changes: 61 additions & 0 deletions run-js-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
#
# Copyright (C) 2026 CERN.
# Copyright (C) 2026 CESNET.
#
# Run JavaScript tests for this repository.

set -o errexit
set -o nounset

# Use WORKING_DIR from environment if provided (CI), otherwise calculate from script location
if [ -n "${WORKING_DIR:-}" ]; then
JS_DIR="$WORKING_DIR"
else
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
JS_DIR="$SCRIPT_DIR/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records"
fi

WATCH_MODE=false

cd "$JS_DIR"

# Parse arguments
for arg in "$@"; do
case ${arg} in
-i|--install)
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi
exit 0
;;
-w|--watch)
WATCH_MODE=true
shift
;;
-h|--help)
echo "Usage: ./run-js-tests.sh [options] [npm test options]"
echo ""
echo "Options:"
echo " -i, --install Install dependencies only"
echo " -w, --watch Run tests in watch mode (default: CI mode)"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " ./run-js-tests.sh Run tests once (CI mode - default)"
echo " ./run-js-tests.sh -w Run tests in watch mode"
echo " ./run-js-tests.sh --testPathPattern=DepositFilesService"
exit 0
;;
esac
done

# Default to CI mode (non-watch) unless -w/--watch is specified
if [ "$WATCH_MODE" = false ]; then
CI=true npm test -- --watchAll=false "$@"
else
npm test -- "$@"
fi
Loading