worksome/pest-graphql-coverage
最新稳定版本:v0.3.9
Composer 安装命令:
composer require worksome/pest-graphql-coverage
包简介
A plugin for Pest to add GraphQL coverage via Lighthouse
README 文档
README
This plugin adds support for showing the coverage of the GraphQL schema (Lighthouse only).
Supports Pest 3 and Pest 4 - automatically detects and works with both versions.
Installation
You can install the package via composer:
composer require --dev worksome/pest-graphql-coverage
Usage
To enable it simply add --gql-coverage argument to your test command
php artisan test --gql-coverage
It can even be used together with parallel
php artisan test --gql-coverage -p
Setting coverage limits
By adding the argument --gql-min=<percentage>, we can limit to have a min coverage of x.
php artisan test --gql-coverage --gql-min=60
Setting the number of output fields
By adding the argument --gql-untested-count=<max>, we can increase or reduce the number of untested fields
that are output.
php artisan test --gql-coverage --gql-untested-count=25
Changing default schema fetching command
By default, it will fetch the schema using php artisan lighthouse:print-schema, however if you have a
custom command for fetching the schema, that can be used instead by adding --schema-command argument
php artisan test --gql-coverage --schema-command="php artisan lighthouse:print-schema-v2"
Excluding nodes from total coverage
By default, all nodes will be included when calculating coverage. However, if you have nodes such as the built-in
Lighthouse pagination types that you do not want to be covered, you can configure ignored fields from your Pest.php configuration file.
<?php declare(strict_types=1); use Worksome\PestGraphqlCoverage\Config as GraphQLCoverageConfig; GraphQLCoverageConfig::new() ->ignore([ 'PaginatorInfo.count', // ... ]); // Exclude all paginator info nodes GraphQLCoverageConfig::new() ->ignorePaginatorInfo(); // Exclude all deprecated fields GraphQLCoverageConfig::new() ->ignoreDeprecatedFields();
Native Pest usage
This also works natively with Pest (without using Artisan), as it is a Pest plugin.
vendor/bin/pest --gql-coverage
Version Compatibility
This package supports both Pest 3 and Pest 4:
- Pest 3: Requires PHP 8.2+
- Pest 4: Requires PHP 8.3+
The package will automatically work with whichever version of Pest you have installed. No code changes are required when upgrading from Pest 3 to Pest 4.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 283.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-01