How to run tests with Laravel Sail in Visual Studio Code

Table of contents:

# Watch tutorial

# Install Better PHPUnit plugin for Visual Studio Code

Better PHPUnit is a plugin for Visual Studio Code that allows you to run PHPUnit tests.

# Configure Better PHPUnit plugin to use Laravel Sail

Use in your settings.json file:

 {
  /**
  * Better PHPUnit
  **/
  //? Command in Sail like "sail test":
  "better-phpunit.phpunitBinary": "test",
  // "better-phpunit.phpunitBinary": "phpunit",
  "better-phpunit.docker.enable": true,
  "better-phpunit.docker.command": "./vendor/bin/sail",
  "better-phpunit.docker.paths": {
      //? Path to Laravel project:
      "/home/alexios/projects/test/laravel": "."
  },
 }