{"id":15673242,"url":"https://github.com/dansysanalyst/pest-snippets","last_synced_at":"2025-05-06T22:25:24.488Z","repository":{"id":143573037,"uuid":"376327425","full_name":"dansysanalyst/pest-snippets","owner":"dansysanalyst","description":"✂️ Code Snippets for writing Pest PHP tests in VSCode","archived":false,"fork":false,"pushed_at":"2023-03-20T13:24:10.000Z","size":5054,"stargazers_count":19,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T03:32:25.534Z","etag":null,"topics":["pest","pestphp","php","vscode","vscode-extension"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dansysanalyst.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-12T15:45:26.000Z","updated_at":"2025-03-23T19:47:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"3637817a-6c1e-446f-bfbe-f09bd5290516","html_url":"https://github.com/dansysanalyst/pest-snippets","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dansysanalyst%2Fpest-snippets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dansysanalyst%2Fpest-snippets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dansysanalyst%2Fpest-snippets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dansysanalyst%2Fpest-snippets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dansysanalyst","download_url":"https://codeload.github.com/dansysanalyst/pest-snippets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252777887,"owners_count":21802662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pest","pestphp","php","vscode","vscode-extension"],"created_at":"2024-10-03T15:38:45.543Z","updated_at":"2025-05-06T22:25:24.455Z","avatar_url":"https://github.com/dansysanalyst.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pest Snippets\n\n**Ready for Pest v2**\n\nPest Snippets is a compilation of code snippets for writing tests with [Pest PHP](https://pestphp.com/).\n\nCode snippets are templates for the codes you use most often.\n\nUsing snippets allows you to write code faster, boosting your productivity, and preventing mistakes.\n\n⭐ Please consider starring the [GitHub repository](https://github.com/dansysanalyst/pest-snippets) if you find this extension useful.\n\n## 🚀 Quick start\n\nJust type `:p` to get a list of all code snippets.\n\nAdditionally, you can type:\n\n- `:pte` to access all `test()` snippets.\n\n- `:pti` to access all `it()` snippets.\n\n- `:pex` to access the available `expect()` methods.\n\n![Screenshot](https://github.com/dansysanalyst/pest-snippets/raw/main/images/screenshot.gif)\n\n## 🗒️ Code Snippet List\n\n### Test templates\n\nPest provides two functions for writing tests: `test()` and `it()`.\n\nType `:pte` + [TAB] to use the `test()` function:\n\n```php\ntest('', function () {\n  //expect()-\u003e\n});\n```\n\nType `:pit` + [TAB] to the `ìt()` function:\n\n```php\nit('', function () {\n  //expect()-\u003e\n});\n```\n\n#### Skipping tests\n\nType `:ptes` / `:pits` to create a test with `skip()`:\n\n```php\ntest('', function () {\n  //...\n})-\u003eskip();\n```\n\nType `:petodo` / `:pitodo` + [TAB] to create a test with `todo()`:\n\n```php\ntest('', function () {\n  //...\n})-\u003etodo();\n```\n\n#### Skipping tests (WIP)\n\nWIP stands for \"Work In Progress\".\n\nType `:ptewip` / `:pitwip` to create a test with `skip('wip')`:\n\n```php\ntest('', function () {\n  //...\n})-\u003eskip('wip');\n```\n\n#### Groups of tests\n\nType `:pteg` / `:pitg` + [TAB] to create a test with `group()`:\n\n```php\ntest('', function () {\n  //...\n})-\u003egroup();\n```\n\n#### Datasets\n\nType `:pted` / `:pitd` + [TAB] to create a test with `with()`:\n\n```php\ntest('', function () {\n  //...\n})-\u003ewith();\n```\n\nType `:pteld` / `:pitld` + [TAB] to create a test with `with()` using Lazy datasets:\n\n```php\ntest('', function () {\n  //...\n})-\u003e with(function () {\n  yield '';\n});\n```\n\n### Exceptions \u0026 Errors\n\nType `:ptet` / `:pitt` + [TAB] to create a test with `throws()`:\n\n```php\ntest('throws exception', function () {\n    //...\n})-\u003ethrows();\n```\n\nType `:ptetif` / `:pittif` + [TAB] to create a test with `throwsIf()`:\n\n```php\ntest('throws exception if...', function () {\n    //...\n})-\u003ethrowsIf();\n```\n\nType `:penoex` / `:pitnoex` + [TAB] to create a test with `throwsNoExceptions()`:\n\n```php\ntest('throws no exceptions', function () {\n    //...\n})-\u003ethrowsNoExceptions();\n```\n\n### Setup and teardown\n\nType `:pbe` + [TAB] to create a `beforeEach()` function:\n\n```php\nbeforeEach(function () {\n  //...\n});\n```\n\nType `:pae` + [TAB] to create a `afterEach()` function:\n\n```php\nafterEach(function () {\n  //...\n});\n```\n\nType `:pba` + [TAB] to create a `beforeAll()` function:\n\n```php\nbeforeAll(function () {\n  //...\n});\n```\n\nType `:paa` + [TAB] to create a `afterAll()` function:\n\n```php\nafterAll(function () {\n  //...\n});\n```\n\n### Expectation API\n\nType `:pex` + [TAB] to create a `expect()` function:\n\n```php\n  expect()\n```\n\nThen, type `:pex` and use your keyboard to move through all the different `expectation` methods.\n\nFor example, type: `pex` + [TAB]  and then `:pextobe` + [TAB] results in:\n\n```php\n  expect()-\u003etoBe()\n```\n\nAvailable `expect()` methods:\n| Trigger                       | Snippet                      |\n| ----------------------------- | ---------------------------- |\n| : `pex`                       | expect()-\u003e                   |\n| : `pextobe`                   | -\u003etoBe()                     |\n| : `pextobearray`              | -\u003etoBeArray()                |\n| : `pextobeempty`              | -\u003etoBeEmpty()                |\n| : `pextobetrue`               | -\u003etoBeTrue()                 |\n| : `pextobetruthy`             | -\u003etoBeTruthy()               |\n| : `pextobefalse`              | -\u003etoBeFalse()                |\n| : `pextobefalsy`              | -\u003etoBeFalsy()                |\n| : `pextobegreaterthan`        | -\u003etoBeGreaterThan()          |\n| : `pextobegreaterthanorequal` | -\u003etoBeGreaterThanOrEqual()   |\n| : `pextobelessthan`           | -\u003etoBeLessThan()             |\n| : `pextobelessthanorequal`    | -\u003etoBeLessThanOrEqual()      |\n| : `pextocontain`              | -\u003etoContain()                |\n| : `pextocontainonlyins`       | -\u003etoContainOnlyInstancesOf() |\n| : `pextohavecount`            | -\u003etoHaveCount()              |\n| : `pextohavemethod`           | -\u003etoHaveMethod()             |\n| : `pextohavemethods`          | -\u003etoHaveMethods()            |\n| : `pextohaveproperty`         | -\u003etoHaveProperty()           |\n| : `pextohaveproperties`       | -\u003etoHaveProperties()         |\n| : `pextomatcharray`           | -\u003etoMatchArray()             |\n| : `pextomatchobject`          | -\u003etoMatchObject()            |\n| : `pextoequal`                | -\u003etoEqual()                  |\n| : `pextoequalcanonicalizing`  | -\u003etoEqualCanonicalizing()    |\n| : `pextoequalwithdelta`       | -\u003etoEqualWithDelta()         |\n| : `pextobein`                 | -\u003etoBeIn()                   |\n| : `pextobeinfinite`           | -\u003etoBeInfinite()             |\n| : `pextobeinstanceof`         | -\u003etoBeInstanceOf()           |\n| : `pextobebool`               | -\u003etoBeBool()                 |\n| : `pextobecallable`           | -\u003etoBeCallable()             |\n| : `pextobefloat`              | -\u003etoBeFloat()                |\n| : `pextobeint`                | -\u003etoBeInt()                  |\n| : `pextobeiterable`           | -\u003etoBeIterable()             |\n| : `pextobenumeric`            | -\u003etoBeNumeric()              |\n| : `pextobeobject`             | -\u003etoBeObject()               |\n| : `pextoberesource`           | -\u003etoBeResource()             |\n| : `pextobescalar`             | -\u003etoBeScalar()               |\n| : `pextobestring`             | -\u003etoBeString()               |\n| : `pextobejson`               | -\u003etoBeJson()                 |\n| : `pextobenan`                | -\u003etoBeNan()                  |\n| : `pextobenull`               | -\u003etoBeNull()                 |\n| : `pextohavekey`              | -\u003etoHaveKey()                |\n| : `pextohavekeys`             | -\u003etoHaveKeys()               |\n| : `pextohavelength`           | -\u003etoHaveLength()             |\n| : `pextobefile`               | -\u003etoBeFile()                 |\n| : `pextobedirectory`          | -\u003etoBeDirectory()            |\n| : `pextobereadabledirectory`  | -\u003etoBeReadableDirectory()    |\n| : `pextobereadablefile`       | -\u003etoBeReadableFile()         |\n| : `pextobewritabledirectory`  | -\u003etoBeWritableDirectory()    |\n| : `pextobewritablefile`       | -\u003etoBeWritableFile()         |\n| : `pextostartwith`            | -\u003etoStartWith()              |\n| : `pextothrow`                | -\u003etoThrow()                  |\n| : `pextoendwith`              | -\u003etoEndWith()                |\n| : `pextomatch`                | -\u003etoMatch()                  |\n| : `pextomatchconstraint`      | -\u003etoMatchConstraint()        |\n| : `pexdd`                     | -\u003edd()                       |\n| : `pexray`                    | -\u003eray()                      |\n| : `pexjson`                   | -\u003ejson()-\u003e                   |\n| : `pexand`                    | -\u003eand()-\u003e                    |\n| : `pexnot`                    | -\u003enot()-\u003e                    |\n| : `pexdef`                    | -\u003edefer()-\u003e                  |\n| : `pexeach`                   | -\u003eeach()-\u003e                   |\n| : `pexsequence`               | -\u003esequence()                 |\n| : `pexwhen`                   | -\u003ewhen()                     |\n| : `pexunless`                 | -\u003eunless()                   |\n| : `pexunless`                 | -\u003eunless()                   |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdansysanalyst%2Fpest-snippets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdansysanalyst%2Fpest-snippets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdansysanalyst%2Fpest-snippets/lists"}