GithubHelp home page GithubHelp logo

balazs4 / vscode-jest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jest-community/vscode-jest

0.0 2.0 0.0 4.55 MB

The optimal flow for Jest based testing in VS Code

License: MIT License

TypeScript 87.99% HTML 4.10% CSS 1.46% JavaScript 6.46%

vscode-jest's Introduction

vscode-jest Build Status

The Aim

A comprehensive experience when using Facebook's Jest within a project.

  • Useful IDE based Feedback
  • Session based test watching

Screenshot of the tool

Features

  • Starts Jest automatically when you're in a root folder project with Jest installed.
  • Show individual fail / passes inline.
  • Show fails inside the problem inspector.
  • Highlights the errors next to the expect functions.
  • Adds syntax highlighting to snapshot files.
  • A one button update for failed snapshots.

How to get it?

Open up VS Code, go search for the extension "Jest".

How to get it set up?

This project has the expectation that you would run something like npm run test which just looks like jest in the package.json. So, please keep your configuration inside the package.json as opposed to using command line arguments.

If have a more complex setup, it can probably be supported, check out the settings. They are all prefixed with jest.

Also, you should use Jest 17+, however 16 works - it will just offer a warning. We're aiming to try and do current Jest version - 1, but won't specifically drop support for older versions unless we're forced into it.

Inspiration

I'd like to give a shout out to Wallaby.js, which is a significantly more comprehensive and covers a lot more editors, if this extension interests you - check out that too.

Troubleshooting

If you don't use the root of your project for you JS with Jest tests, do not worry, you can still use this project. You will need to use the "Start Jest Runner" command, and maybe have to configure your own jest.pathToJest setting inside the .vscode/settings.json to whatever you would use.

These are the activation events which trigger the runner to start:

  "activationEvents": [
    "workspaceContains:node_modules/.bin/jest",
    "workspaceContains:node_modules/react-scripts/node_modules/.bin/jest",
    "onCommand:io.orta.jest.start"
  ],

These are the things that will trigger the extension loading. If one of these applies, and you're not seeing the "Jest" in the bottom bar, run the command Open Developer Tools and see if something has crashed, we'd love to know what that is, and ideally a project we can run against.

Want to Contribute?

The extension is in two parts, one is this repo. It contains all the VS Code specific work.

git clone https://github.com/orta/vscode-jest
cd vscode-jest
yarn install
code .

The other part is inside the Jest source code. It's a node module called "jest-editor-support".

It's very possible that you're going to want to make changes inside here, if you're doing something that touches the test runner process or file parsers. To get that set up to work I'd recommend doing this:

cd ..
git clone https://github.com/facebook/jest.git
cd jest
yarn install

With that installed, you want to use a custom jest-editor-support by going into cd packages/jest-editor-support and running yarn link.

Go back to vscode-jest, and do one more yarn link "jest-editor-support" and now you're using those files directly from master of Jest.

As jest-editor-support requires running through babel, you can run the babel watcher for all jest files by running yarn run watch inside the jest root directory.

Yeah, it's a bit of a process, but we'll be sharing code with the nuclide team and that's worth it IMO.

vscode-jest's People

Contributors

orta avatar bookman25 avatar luizbon avatar gabro avatar vkrol avatar brentatkins avatar

Watchers

James Cloos avatar  avatar

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.