test-ci.js 930 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env node
  2. const { execSync } = require("child_process")
  3. const process = require("process")
  4. try {
  5. if (process.platform === "linux") {
  6. console.log("Detected Linux environment.")
  7. execSync("which xvfb-run", { stdio: "ignore" })
  8. console.log("xvfb-run is installed. Running tests with xvfb-run...")
  9. execSync("xvfb-run -a npm run test:coverage", { stdio: "inherit" })
  10. } else {
  11. console.log("Non-Linux environment detected. Running tests normally.")
  12. execSync("npm run test:integration", { stdio: "inherit" })
  13. }
  14. } catch (error) {
  15. if (process.platform === "linux") {
  16. console.error(
  17. `Error: xvfb-run is not installed.\n` +
  18. `Please install it using the following command:\n` +
  19. ` Debian/Ubuntu: sudo apt install xvfb\n` +
  20. ` RHEL/CentOS: sudo yum install xvfb\n` +
  21. ` Arch Linux: sudo pacman -S xvfb`,
  22. )
  23. } else {
  24. console.error("Error running tests:", error.message)
  25. }
  26. process.exit(1)
  27. }