jest-runner-phpunit

0.0.7 • Public • Published

CircleCI npm version Maintainability

Usage

Install

Install jest(it needs Jest 21+) and jest-runner-phpunit

# jest-runner-phpunit assumes phpunit is installed with composer
composer require --dev phpunit/phpunit

# Install with yarn
yarn add --dev jest jest-runner-phpunit

# or with NPM

npm install --save-dev jest jest-runner-phpunit

Add it to your Jest config

Standalone

In your package.json

{
  "jest": {
    "runner": "jest-runner-phpunit",
    "displayName": "phpunit",
    "moduleFileExtensions": ["php"],
    "testMatch": ["<rootDir>/tests/**/*Test.php"]
  }
}

Or in jest.config.js

module.exports = {
  runner: 'jest-runner-phpunit',
  "displayName": "phpunit",
  "moduleFileExtensions": ["php"],
  testMatch: ['<rootDir>/tests/**/*Test.php'],
}

Please update testMatch to match your project folder structure

Alongside other runners

It is recommended to use the projects configuration option to run multiple Jest runners simultaneously.

If you are using Jest <22.0.5, you can use multiple Jest configuration files and supply the paths to those files in the projects option. For example:

// jest-test.config.js
module.exports = {
  // your Jest test options
  displayName: 'test'
}

// jest-phpunit.config.js
module.exports = {
  // your jest-runner-phpunit options
  runner: 'jest-runner-phpunit',
  displayName: "phpunit",
  moduleFileExtensions: ["php"],
  testMatch: ['<rootDir>/tests/**/*Test.php']
}

In your package.json:

{
  "jest": {
    "projects": [
      "<rootDir>/jest-test.config.js",
      "<rootDir>/jest-phpunit.config.js"
    ]
  }
}

Or in jest.config.js:

module.exports = {
  projects: [
    '<rootDir>/jest-test.config.js',
    '<rootDir>/jest-phpunit.config.js'
  ]
}

If you are using Jest >=22.0.5, you can supply an array of project configuration objects instead. In your package.json:

{
  "jest": {
    "projects": [
      {
        "displayName": "test"
      },
      {
        "runner": "jest-runner-phpunit",
        "displayName": "phpunit",
        "moduleFileExtensions": ["php"],
        "testMatch": ["<rootDir>/tests/**/*Test.php"]
      }
    ]
  }
}

Or in jest.config.js:

module.exports = {
  projects: [
    {
      displayName: 'test'
    },
    {
      runner: 'jest-runner-phpunit',
      displayName: "phpunit",
      moduleFileExtensions: ["php"],
      testMatch: ['<rootDir>/tests/**/*Test.php']
    }
  ]
}

Run Jest

yarn jest

Readme

Keywords

Package Sidebar

Install

npm i jest-runner-phpunit

Weekly Downloads

12

Version

0.0.7

License

MIT

Unpacked Size

13.1 kB

Total Files

7

Last publish

Collaborators

  • olyckne