0

I'm trying to debug in VS Code. I've created the launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}/conf/conf.js",
        }
    ]
}

I'm using Jasmine and in my conf.js file (I'm using the file from the example when I installed Protractor), it starts with exports.config = { but it has 3 dots showing under it. When I click on the light bulb, it says "Convert to ES6 Module"

When I debug, it doesn't step into the code and just jumps to the end, even if I put breakdowns.

My conf.js file:

exports.config = {
  directConnect: true,

  capabilities: {
    'browserName': 'chrome'
  },

  framework: 'jasmine',

  specs: ['../specs/horses.js'],

  jasmineNodeOpts: {
    defaultTimeoutInterval: 30000
  },
};

When I run: protractor .\conf\conf.js in the Terminal, it works fine. I have a non-angular page.

  • Does this answer your question? [How to debug protractor in VS CODE?](https://stackoverflow.com/questions/54016095/how-to-debug-protractor-in-vs-code) – DublinDev Feb 20 '20 at 11:33

1 Answers1

0

Update

I misunderstood your original question so here is a config that should work. Basically the program property needs to point to protractor and you pass your conf.js using the args property

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/node_modules/protractor/bin/protractor",
            "args": ["${workspaceRoot}/conf/conf.js"],
            "outFiles": [ "${workspaceRoot}/out/*.js" ]
        }
    ]
}

See this article and this previous question for more information.

Original Incorrect Ans

The config file is exporting an object and therefore only has one action that can be debugged and that is export of the config object itself. The properties you are exporting, like specs, jasmineNodeOptions are called at different times during the setup process when protractor launches and not actually doing anything at the time they are exported. If you introduced some executable code in a lifecycle hook, like a beforeLaunch or onPrepare and tried to debug that it would likely work as you are expecting

DublinDev
  • 2,318
  • 2
  • 8
  • 31
  • Thank you, but I don't quite understand what you mean. How do I call the spec file then? – Tina Cummins Feb 14 '20 at 05:31
  • Sorry maybe I misunderstood what you were referring to actually. Are you putting the breakpoints in executable spec files or are you putting them in your conf.js file? For instance in these [images](https://imgur.com/a/O9qMLNv) the breakpoints will not work in the conf file but should work for the spec. – DublinDev Feb 14 '20 at 09:29
  • It doesn't want to step into my spec file, even if I put breakpoints in the spec file. – Tina Cummins Feb 20 '20 at 09:46
  • @TinaCummins Ok, I've updated my answer. Can you try once more – DublinDev Feb 20 '20 at 09:59