Giter VIP home page Giter VIP logo

neotest-pest's Introduction

neotest-pest

Caution

This package has been archived and will receive no more updates. Please consider switching to V13Axel/neotest-pest.

Tests

This plugin provides a Pest adapter for the Neotest framework.

⚠️ This plugin is still in the early stages of development. Please test against your Pest tests ⚠️

📦 Installation

Install the plugin using packer:

use({
  'nvim-neotest/neotest',
  requires = {
    ...,
    'theutz/neotest-pest',
  },
  config = function()
    require('neotest').setup({
      ...,
      adapters = {
        require('neotest-pest'),
      }
    })
  end
})

🔧 Configuration

The plugin may be configured as below:

adapters = {
  require('neotest-pest')({
    pest_cmd = function()
      return "vendor/bin/pest"
    end
  }),
}

🚀 Usage

Test single method

To test a single test, hover over the test and run lua require('neotest').run.run()

Test file

To test a file run lua require('neotest').run.run(vim.fn.expand('%'))

Test directory

To test a directory run lua require('neotest').run.run("path/to/directory")

Test suite

To test the full test suite run lua require('neotest').run.run({ suite = true })

🎁 Contributing

This project is maintained by the Neovim PHP community. Please raise a PR if you are interested in adding new functionality or fixing any bugs. When submitting a bug, please include an example test that we can test against.

To trigger the tests for the adapter, run:

./scripts/test

👏 Prior Art

This package is insanely reliant on the excellent efforts put into olimorris/neotest-phpunit by @olimorris.

neotest-pest's People

Contributors

theutz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

neotest-pest's Issues

Pest 2.0 breaks result parsing

It looks like Pest 2.0 requires phpunit >10, which has broken test result parsing. Not sure if this is something there's an easy solution to, that I am just perhaps overlooking? But since I could reproduce it on this very repo's examples, I thought I'd at least bring it up in case this project is not as abandoned as it seems 😅

You can reproduce it by cloning this very repository, updating Pest to 2.0, then doing a lua require('neotest').run.run() on any test, where you'll see all tests, pass or fail, are being (wrongly) parsed as failing.

I spent a few hours last night trying to get familiar with neotest by looking through the neotest-pest and neotest-phpunit, but so far I can't quite figure out exactly where the parsing breaks down - but what I have done so far is compare the output of --log-junit between the two.

Here's phpunit 9:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="/path/to/repo/tests/Unit/ExampleTest.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.002297">
    <testsuite name="P\Tests\Unit\ExampleTest" file="/path/to/repo/tests/Unit/ExampleTest.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.002297">
      <testcase name="true is true" class="Tests\Unit\ExampleTest" classname="Tests.Unit.ExampleTest" file="/path/to/repo/tests/Unit/ExampleTest.php" assertions="1" time="0.002297"/>
    </testsuite>
  </testsuite>
</testsuites>

And here's phpunit 10:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="Tests\Unit\ExampleTest" file="tests/Unit/ExampleTest.php" tests="1" assertions="1" errors="0" failures="0" skipped="0" time="0.004544">
    <testcase name="true is true" file="tests/Unit/ExampleTest.php::true is true" class="Tests\Unit\ExampleTest" classname="Tests.Unit.ExampleTest" assertions="1" time="0.004544"/>
  </testsuite>
</testsuites>

I'm going to continue digging into it, but I'd love some input from anyone who knows neotest better than I do (which is barely)! 😄

Automatically detect and use Pest through Sail if exists

Hello!

I'm running Laravel under Docker in my local environment, but use the sail to interact with the container.

Can you please have this plugin automatically detect and use sail? I believe this is what vim-test does for PHPUnit.

Thanks!

No tests found

I am using this plugin in Laravel application. I have followed the installation process very closely. Yet when I run lua require('neotest').run.run() , I get No test found. Any idea how to debug this?

Pest single run gets detected wrongly

Thank you for this nice plugin.

There seems to be a problem with the parsing of test results.

This test

test('auth user', function () {
    $this->get('/')
        ->assertOk();
});

passes but when i run

:lua require("neotest").run.run() 

It gets marked as failing in neotest.

When I use

:lua require("neotest").run.run("tests") 

all tests run and it gets marked as green correctly.

Please let me know if I can provide additional information.

Ignore vendor folder when running test suite

I can't find a way to get the test suite to ignore the vendor directory in a laravel project. I have the discovery attribute of neotest config set to ignore the file but as far as I can tell it just makes the vendor folder not show up in the status window.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.