Giter Site home page Giter Site logo

debug-breakpoint-example's Introduction

This repository exposes an issue with using vscode-js-debug in the cases where program is a wrapper used to determine an actual file.

For purposes of the example, the compiled files and sourcemaps are available in ./dist

Setup

npm install

The Problem

Given the configuration

{
  "type": "node",
  "request": "launch",
  "name": "Debug Current Test File",
  "program": "${workspaceFolder}/bin/mocha-current-file",
  "args": [
    "${file}"
  ],
  "outFiles": [
    "${workspaceFolder}/dist"
  ],
  "sourceMaps": true,
}

The file ./bin/mocha-current-file.js does the following:

  • consumes the ${file} argument, which is the currently focused file in the vscode editor. In this example, it is src/index.unit.ts
  • determines the name and location of the compiled typescript file, in this case, dist/index.unit.js
  • Shows an (unfollowed) example of a setup where there might be complicated "before all test" setup, e.g. for cleanly creating and tearing down databases.
  • invokes mocha through require('mocha/lib/cli').main(['dist/index.unit.js])

You can substitute your favorite test framework, this also happens with Jest and AVA.

Examples

Given these breakpoints: ./img/setup.png

When not using the preview.

// settings.json
{
    "debug.javascript.usePreview": false,    
}

./img/preview-false.png

Note how we are currently stopped on the breakpoint in the source file.

When using the preview

// settings.json
{
    "debug.javascript.usePreview": false,    
}

./img/with-preview.png Note how we are currently stopped on the debugger; line in the compiled distfile ./dist/index.unit.js

Traces

Traces are committed to ./tracefile.json

debug-breakpoint-example's People

Contributors

mschnee avatar

Watchers

 avatar  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.