Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

phuocbt's avatar

CI/CD run unit test

I want to run CI/CD on gitlab, to run unit tests, my laravel combines with reactjs (vite), but when I run npm run I get the error below

Error: ENOSPC: System limit for number of file watchers reached, watch '/builds/deha-soft/jmu/otpo01/otpo01/laravel/vendor/fakerphp/faker/src/Faker/Provider/Address.php'
    at FSWatcher.<computed> (node:internal/fs/watchers:247:19)
    at Object.watch (node:fs:2418:34)
    at createFsWatchInstance (file:///builds/deha-soft/jmu/otpo01/otpo01/laravel/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:52093:17)
    at setFsWatchListener (file:///builds/deha-soft/jmu/otpo01/otpo01/laravel/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:52140:15)
    at NodeFsHandler._watchWithNodeFs (file:///builds/deha-soft/jmu/otpo01/otpo01/laravel/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:52295:14)
    at NodeFsHandler._handleFile (file:///builds/deha-soft/jmu/otpo01/otpo01/laravel/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:52359:23)
    at NodeFsHandler._addToNodeFs (file:///builds/deha-soft/jmu/otpo01/otpo01/laravel/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:52601:21)
Emitted 'error' event on FSWatcher instance at:
    at FSWatcher._handleError (file:///builds/deha-soft/jmu/otpo01/otpo01/laravel/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:53792:10)
    at NodeFsHandler._addToNodeFs (file:///builds/deha-soft/jmu/otpo01/otpo01/laravel/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:52609:18) {
  errno: -28,
  syscall: 'watch',
  code: 'ENOSPC',
  path: '/builds/deha-soft/jmu/otpo01/otpo01/laravel/vendor/fakerphp/faker/src/Faker/Provider/Address.php',
  filename: '/builds/deha-soft/jmu/otpo01/otpo01/laravel/vendor/fakerphp/faker/src/Faker/Provider/Address.php'
}
0 likes
1 reply
phuocbt's avatar
stages:
  - test
  # - deploy

cache:
  paths:
    - laravel/vendor/
    - laravel/node_modules/

unit_test:
  stage: test
  image: php:8.3-cli
  services:
    - mysql:5.7
  variables:
    MYSQL_DATABASE: laravel_test
    MYSQL_USER: user
    MYSQL_PASSWORD: secure_password
    MYSQL_ROOT_PASSWORD: root_password
    DB_HOST: mysql
    DB_CONNECTION: mysql
    DB_DATABASE: laravel_test
    DB_USERNAME: user
    DB_PASSWORD: secure_password
  before_script:
    - apt-get update -yqq
    - apt-get install -yqq libexif-dev unzip zip
    - apt install nodejs -yqq
    - apt install npm -yqq
    - docker-php-ext-install pdo_mysql exif
    - cd laravel
    - curl -sS getcomposer.org/installer | php
    - mv composer.phar /usr/local/bin/composer
    - composer update
    - npm install
    - cp .env.example .env
    - php artisan key:generate
    - php artisan config:clear
    - php artisan migrate --env=testing --seed
  script:
    - node -v
    - LARAVEL_BYPASS_ENV_CHECK=1 npm run dev
    - php artisan test
  tags:
    - sonarqube
  only:
    - develop

Please or to participate in this conversation.