0.0.7 • Published 5 years ago

jest-runner-phpunit v0.0.7

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

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
0.0.7

5 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago