Coder Social home page Coder Social logo

prashaantt / node-tdd Goto Github PK

View Code? Open in Web Editor NEW
22.0 4.0 10.0 420 KB

VS Code TDD extension for Node and JavaScript

Home Page: https://marketplace.visualstudio.com/items?itemName=prashaantt.node-tdd

License: MIT License

TypeScript 100.00%
javascript nodejs testing vscode

node-tdd's Introduction

node-tdd

A Visual Studio Code extension to ease test-driven development in Node and JavaScript.

Features

node-tdd demo

  • Activates when a workspace containing package.json is opened.
  • Triggers an automatic test build whenever source files are updated.
  • Shows a colour-coded build summary.
  • Shows the average test coverage (experimental).
  • Optionally, if your test runner generates TAP outputs, use the nodeTdd.reporter setting to provide a more meaningful test summary:

tap

  • Finally, use nodeTdd.minimal to reclaim some status bar real estate:

minimal mode

Settings

This extension contributes the following settings:

Setting Type Default Description
nodeTdd.activateOnStartup boolean true Activate TDD mode when workspace is opened
nodeTdd.testScript string test The npm script to run tests
nodeTdd.glob string {src,test}/**/*.{js,ts,jsx,tsx} The glob pattern for files to watch, relative to the workspace root
nodeTdd.verbose boolean / object false / {onlyOnFailure: true} Show build status dialogs
nodeTdd.minimal boolean false Minimise status bar clutter
nodeTdd.buildOnActivation boolean false Run tests when TDD mode is activated
nodeTdd.buildOnCreate boolean false Run tests when matching files are created
nodeTdd.buildOnDelete boolean false Run tests when matching files are deleted
nodeTdd.showCoverage boolean false Show the average test coverage if reported (experimental)
nodeTdd.coverageThreshold number / null null The coverage threshold percentage, used to colour-code the coverage
nodeTdd.reporter string / null null The test reporter used (currently only "tap" is supported)

Commands

The following commands are available from the commands menu as well as status bar buttons:

Command Action
activate Activate node-tdd in a workspace
deactivate Deactivate node-tdd in a workspace
toggleOutput Toggle detailed test results output
stopBuild Stop a running build

Limitations and known issues

  • The extension doesn't get activated if package.json was not initially present when the workspace was opened; a window restart will be required to detect a change.
  • It doesn't work with watch mode/incremental test builds. The build process used for running tests must exit on each execution, otherwise it will never report the status.
  • showCoverage is an experimental setting that currently only works with the text-summary reports from Lab, Istanbul and nyc. Disable it if it doesn't work for you or its output looks funny.
  • Despite recent fixes, it might still be flaky on Windows. Please report any issues.
  • Ironically for a TDD extension, it has very few tests of its own because I don't yet know how to test UI elements in VS Code. :/

Suggestions and PRs are welcome.

Release notes

See the change log. If you are reading this from within VS Code, click on the Changelog tab of the extension preview page.

License

MIT License.

node-tdd's People

Contributors

prashaantt avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

node-tdd's Issues

Support custom scripts instead just npm tasks

Maybe you could allow the user to specify which command to execute for a test and also take a filepath that just contains a coverage value ("87.95") and then use those values to output the data. that way one could write wrappers for any language/framework and use it very easily. the extension itself is really beautiful so it would be a shame not being able to use it because of other languages.

StatusBarItem priorities are off

All three statusbaritems have a different priority (2, 1 and 0). This conflicts with other extensions that add statusbaritems with a certain priority.
image
I would suggest keeping the priority the same for all items, so they stay together. This might still cause issues because the statusbaritems are added/removed based on available info. I would suggest creating them once, and leaving them. That way, they will always stay together.

If you save with the test results panel open, a new build should not start

I often consult to the results of my tests, making changes to multiple files before being satisfied that I've fixed a test failure. However after I save the first file I change, the entire build starts over, which takes a while.

If that seems extreme, maybe a compromise could be that it could be a setting, or perhaps it could ask you if you want to build again.

Installed but not showing in VS Code anymore

Hello,

I have been waiting to use your plug-in. It seems like just the tool that I need for my serverless development. When I first installed it, I saw it per your video in the status bar. However, now that I want to use it, it is not there. I have tried to uninstall, reinstall, etc and I can get it installed but it doesn't show up. I have checked that it is enabled, etc as well and it is. If you have any insight as to why it would not be in the status bar anymore I would greatly appreciate it. I will attach a few screenshots below for your reference.

What the status bar looks like:
image

What the extension status is:
image

Version Information:
image

Looking forward to fixing this soon!

Cheers,
Ryan

Add option to explode spectacularly but succeed silently

I've only recently found node-tdd and I've got to say, this might just change how i develop software.
I would however like to see an option to display failed builds in a more visual manner.
If a build is successful the green check-mark is absolutely enough, but when a build fails i want to know about it immediately and spectacularly (on my 4k laptop display the little "Failing" text is about 4mm (0.15") tall).

It doesn't even have to be that fancy to begin with, just allowing for a verbose output if the build fails would be enough.

TDD is not working on my windows machine

Hi @prashaantt ,

I have Visual Studio Code v1.15.1 with Node TDD plugin. I can see the symbol in status bar which means that it is activated. However, it is not getting invoked at all. Am I missing something? It is not very clear from project readme.
vscodetdd

Thanks,
Sanjeev

Terminal output setting

It would be nice to have a terminal instead of the output when toggle the status, because of the current vscode limitation about colors on the output window:

See here:
microsoft/vscode#243

Check out the comment from bartlewis he says how to open a new terminal by sending a command to execute.

This would be great to see the colors on the tests reports, which are very important.

Stuck in building...

When I activate the extension nothing happens except the text building... keeps rolling over and over.

The npm script that is refered in setting works manually. When I look at output for the extension there is none.

Any help would be super nice!

package.json was not found

This messages appears "package.json was not found" while a package.json is located in my project root folder.

Support for running bash command/docker command

I currently run my node app in a docker container and have custom make commands to run tests inside the container. I love the TDD extension in my non-docker apps and I would love to use it docker apps too. Adding the ability to be able to use docker-compose run npm/yarn test would be great

Not displaying the tests passed and % coverage

The results are not displayed in the status bar. I have restarted everything NodeTDD extension, VS Code and Laptop.

I am using the following :

  • macOS High Sierra Version 10.13.6
  • VS Code Version 1.29.1 (1.29.1)
  • Node Version : 11.2.0
  • Mocha Version : 5.2.0
  • NodeTDD version : 0.2.4

The bug screen shot :
TDD results not shown

Zipped Project Folder is also attached for reference :

mocha-TDD.zip

Parse nyc output

Istanbul is being re-written as nyc, whose default output is currently not being parsed by node-tdd.

Clicking should show you the current build progress, not cancel the build.

Hey @prashaantt! Gotta say, I love your plugin and I use it every day! ๐Ÿ˜

The only thing that I think could be improved is that it would be really nice if clicking on the "Building..." label would simply show you the progress of the build (as clicking on "Passing" does), rather than canceling the build.

I find that I want to see the progress of the build much more often than I want to cancel the build.

The behavior for canceling the build could still be preserved. Perhaps there could be a small X icon to cancel the build that would show only while the build was, ah, building. ๐Ÿ˜„

Anyway, again this plugin is great. Simple and effective. Thanks for your work!

"nodeTdd.glob" won't work recursive [WINDOWS]

First of all:
Thanks for the great plug-in. This will ease my daily work ๐Ÿ‘

Unfortunately when setting the glob to something like:

    "nodeTdd.glob": "{src,spec}/**/*.{js,ts,jsx,tsx}"

The '**' will only match exactly one folder level. Not more, not less. I would have assumed that it'd find spec files in sub folders as and in the spec and src folders as well.

I am running code on Windows. Is this an expected/known behavior?

Please also check following visualization:

spec
|-- spec1.js // changes here will be ignored
|-- folder
    |---- spec2.js // changes here will trigger new test run
    |---- anotherFolder
          |----------- spec3.js // changes here will be ignored

Does this work with AVA?

I run my tests with AVA, but I never see the status bar update.

No output in the console under TDD.

Thanks.

Issue Running on Windows 10

Really excited about this extension. However I have yet to get it to work. I opened a typescript workspace with a package.json and nothing happens. Here are some things I have observed:

  • I checked the TDD output and it isnt outputting any information.
  • I have changed some settings but it doesnt seem to do anything.
  • I am on windows 10 and on the latest VS Code.
  • I have opened multiple workspaces and the result is the same

I would love to supply some logs or some debug information if you can point me where to find them.

TDD misconception

I've stumbled upon this extension and my first impression was: Wow! Awesome idea! Unfortunately, it works really weird as of a TDD-helper.

TDD is about iterating on a single unit, so it's completely useless and a waste of time to run whole test suite on a single test/implementation change - that's not TDD, that's regression checking if your change did not affect other parts of the system. IMO it should only work just for the opened file.

Any reasons why this went the way it went? And are there any plans to make it work on single files?

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.