Admin
dashboard
file manager
command
php exec
/
/
var
/
www
/
html
/
distribution-prod
/
cms-react
/
scripts
path:
go
upload
mkdir
name
type
size
perms
modified
actions
[parent directory]
run-tests.mjs
file
1,750 B
0664
2026-04-26 14:51:28
edit
delete
rename
editing: run-tests.mjs
import { spawnSync } from 'node:child_process' import { readdirSync, statSync } from 'node:fs' import path from 'node:path' import process from 'node:process' import { fileURLToPath } from 'node:url' const scriptDir = path.dirname(fileURLToPath(import.meta.url)) const projectDir = path.resolve(scriptDir, '..') const srcDir = path.join(projectDir, 'src') const testPattern = /\.(test|spec)\.(cjs|mjs|js|jsx|ts|tsx)$/ function collectTestFiles(dir) { const entries = readdirSync(dir, { withFileTypes: true }) return entries.flatMap((entry) => { const entryPath = path.join(dir, entry.name) if (entry.isDirectory()) { return collectTestFiles(entryPath) } return testPattern.test(entry.name) ? [entryPath] : [] }) } function run(command, args) { const result = spawnSync(command, args, { cwd: projectDir, stdio: 'inherit', shell: process.platform === 'win32', }) process.exit(result.status ?? 1) } const testFiles = statSync(srcDir).isDirectory() ? collectTestFiles(srcDir) : [] const forwardedArgs = process.argv.slice(2).filter((arg) => arg !== '--run') if (testFiles.length === 0) { console.log('No frontend test files found in cms-react/src. Running build smoke check instead.') run('npm', ['run', 'build']) } const unsupportedFiles = testFiles.filter((file) => /\.(jsx|ts|tsx)$/.test(file)) if (unsupportedFiles.length > 0) { console.error('Found frontend test files, but no TS/JSX test runner is configured:') for (const file of unsupportedFiles) { console.error(`- ${path.relative(projectDir, file)}`) } console.error('Install a dedicated frontend test runner to execute these files.') process.exit(1) } run(process.execPath, ['--test', ...forwardedArgs, ...testFiles])
save
cancel