Search code examples
javascriptdebuggingmocha.jsbabeljswebdriver-io

Webdriverio debug BDD tests using WebStorm


Is there any way to debug Webdriverio tests using nodeJS and WebStorm? I've found some conclusion here and this is actually my problem: Run WebdriverIO tests via Mocha in WebStorm But this solution doesn't fit to my problem now; I've set up Babel to compile my BDD tests I've set tests.config.js

module.exports = {     maxInstances: 1,
capabilities: [{ browserName: 'chrome' }],
execArgv: ['--inspect'] : [],
specs: ['**/some/spec.js']
mochaOpts: {
        ui: 'bdd',
        compilers: ['js:@babel/register'],
        timeout: 150000
} }

and babel.conf.js

module.exports = {
presets: [
    ['@babel/preset-env', {
        targets: {
            node: 12
        }
    }]
]

}

then I've created nodeJS configuration like it said here at answer: Run WebdriverIO tests via Mocha in WebStorm Set breakpoint at test

describe("test", function(){ 
it ("this is a BDD test", 
function(){
breakpoint here>> do_some_action();
})
})

But when I try to launch my tests in debug mode nothing happens and I see "connnected to localhost:port" message. and I can't go to breakpoint; there are no errors;


Solution

  • there was problem with a wdio.conf.js file. If you don't set specs file >> there aren't no errors. But launching is incorrect. I've set config like this:

    module.exports =
    {
    capabilities: [{
    maxInstances: 6,
    browserName: 'chrome',
    baseUrl: "some-url/",
    browserVersion: '67.0'}]
    specs: [
    './this/is/spec.js']
    mochaOpts: {
    ui: 'bdd',
    require: ['@babel/register'],
    timeout: 150000
    },
    

    And debug works after this. It's not too har as I though :) If there are some questions - > I'm glad o answer