nothingworksinc / ticketbeast

Back to the lesson videos:
https://course.testdrivenlaravel.com/lessons
552 stars 11 forks source link

Sublime text shortcut jealousy (Atom package) #39

Open itmecho opened 7 years ago

itmecho commented 7 years ago

Hi everyone!

I'm doing this as an issue as I'm not sure where the best place to put this is!

I got jealous of Adam's Sublime Text plugin to run phpunit so I decided to write my first Atom package to achieve the same goal! It displays the results in a notification at the moment but hopefully when I figure out using panels, it can have it's own panel for displaying the output.

You can find it here: https://atom.io/packages/atom-phpunit

Again, it's my first Atom package and my JS isn't overly strong so any feedback would be appreciated!

Thanks guys!

adamwathan commented 7 years ago

Awesome! 🙌

danielcheasman commented 7 years ago

Hey,

Neat idea, I'm not a huge fan of Sublime either and have been using process-palette (https://atom.io/packages/process-palette) in Atom to create custom PHPUnit, Composer and Laravel commands as keyboard shortcuts and actions in the command palette.

I'd highly recommend it as it saves window switching to the terminal for common Laravel tasks!

My PHPUnit definition if anyone wants a starting point:

{
      "namespace": "PHPUnit",
      "action": "Run",
      "command": "phpunit",
      "arguments": [],
      "cwd": "{fileProjectPath}",
      "inputDialogs": [],
      "env": {},
      "keystroke": "shift-alt-p",
      "stream": true,
      "outputTarget": "panel",
      "outputBufferSize": 80000,
      "maxCompleted": 1,
      "autoShowOutput": true,
      "autoHideOutput": false,
      "scrollLockEnabled": false,
      "singular": false,
      "promptToSave": true,
      "saveOption": "none",
      "patterns": [
        "default"
      ],
      "successOutput": "{stdout}",
      "errorOutput": "{stdout}\n{stderr}",
      "fatalOutput": "Failed to execute : {fullCommand}\n{stdout}\n{stderr}",
      "successMessage": "Tests Passed ✓",
      "errorMessage": "Tests Failed.\nReturned with code {exitStatus}",
      "fatalMessage": "Failed to execute : {fullCommand}\n{stdout}\n{stderr}"
    }
mkarnicki commented 7 years ago

Hi guys,

You can check out this Atom plugin as well. I have it set to: alt-, phpunit:current alt-. phpunit:alltests alt-/ phpunit:hide

The thing I like about @Synapse791 's plugin is the color feedback. The plugin I mention doesn't use colors to indicate success/failure, though I'm guessing it would be easy to add such behavior. The thing I don't like about @Synapse791 's plugin is inconsistent location of the 'close notification' cross icon (well, because these are notifications), but when this will make use of panels it'll be pretty awesome 👍 Props for writing your first plugin, buddy!

The most significant con of the plugin I mention is there's no phpunit:single command to only run the single test with cursor focus. You can run tests from current file or from whole project.

itmecho commented 7 years ago

Thanks for the feedback!

@mkarnicki Just to let you know I've released 1.2.0 which shows the failure and error output in a panel :smile:

mkarnicki commented 7 years ago

@Synapse791 I'll def check it out! Keep on rocking buddy 👍

curtisblackwell commented 7 years ago

I added a couple gulp tasks for this:

const gulp  = require('gulp');
const spawn = require('child_process').spawn;

// Run PHPUnit tests.
gulp.task('phpunit', () => {
  spawn('./vendor/bin/phpunit', [], {
    stdio: 'inherit',
  }).on('close', () => {
    console.log('\n\n\n\n');
    console.log('--------------------------------------------------------------------------------');
    console.log('\n\n\n\n');
  });
});

// Run tests when files change.
gulp.task('test:watch', () => {
  gulp.watch(
    [
      'app/**/*.php',
      'database/factories/*.php',
      'database/migrations/*.php',
      'resources/views/**/*.php',
      'routes/*.php',
      'tests/**/*.php',
    ],
    ['phpunit']
  );
});
  1. gulp phpunit runs the whole suite.
  2. gulp test:watch watches files and runs the whole suite on change.

Sometimes this is great, other times it's distracting b/c there are expected failures you want to ignore for a bit. I just tried out @Synapse791's Atom package and it's great. Thanks!

I also tried Process Palette, but it was way more powerful/configurable than I need.

stevepop commented 7 years ago

Thanks @Synapse791, I just tried your package and its quite good. Thanks for taking time to do this and sharing!

stevepop commented 7 years ago

By the way @Synapse791, when I had PHPUnit fails, the console panel did not close like when there is a success. I had to reload the window to get back into my code. Is this by design?

itmecho commented 7 years ago

@stevepop If you're all up to date, there should be a keyboard shortcut (Alt+Shift+X) to toggle that panel! I made the panel stay open to enable you to read any long errors. Hope this helps! =]