How to get webriver io typescript working wdio wizard

0 votes

I'm Putting together a WebdriverIO project with TypeScript and Cucumber. I ran the wizard which seems straight forward enough. I selected Cucumber, TypeScript and page object model.

This generates a test/wdio.conf.ts and test/tsconfig.json file as well as a boilerplate Feature file

However when I run the test with the command wdio run test/wdio.conf.ts

I get the following error:

export const config = {
^^^^^^

SyntaxError: Unexpected token 'export'

What is the problem?

test/wdio.conf.ts

export const config = {
    // ...
    autoCompileOpts: {
        autoCompile: true,
        // see https://github.com/TypeStrong/ts-node#cli-and-programmatic-options
        // for all available options
        tsNodeOpts: {
            transpileOnly: true,
            project: 'tsconfig.json'
        },
        // tsconfig-paths is only used if "tsConfigPathsOpts" are provided, if you
        // do please make sure "tsconfig-paths" is installed as dependency
        tsConfigPathsOpts: {
            baseUrl: './'
        }
    }
}

test/tsconfig.json

{
    "compilerOptions": {
        "types": [
            "node",
            "webdriverio/async",
            "@wdio/cucumber-framework",
            "expect-webdriverio"
        ],
        "target": "ES5"
    }
}

package.json

{
    "name": "e2e-wdio",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "wdio": "wdio run test/wdio.conf.ts"
    },
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "@wdio/cli": "^7.16.13",
        "@wdio/cucumber-framework": "^7.16.13",
        "@wdio/local-runner": "^7.16.13",
        "@wdio/spec-reporter": "^7.16.13",
        "chromedriver": "^97.0.0",
        "ts-node": "^10.4.0",
        "typescript": "^4.5.5",
        "wdio-chromedriver-service": "^7.2.6",
        "webdriverio": "^7.16.13"
    }
}
Jul 5, 2022 in TypeSript by Nina
• 3,060 points
1,058 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In TypeSript

0 votes
1 answer

How to get TypeScript definition files via bower?

The best option is to use tsd. It ...READ MORE

answered Jun 10, 2022 in TypeSript by Nina
• 3,060 points
601 views
0 votes
1 answer

How to create ES6 Map in Typescript

Refer this as an example this.configs = new ...READ MORE

answered May 31, 2022 in TypeSript by Nina
• 3,060 points
873 views
0 votes
1 answer

How to declare and initialize a Dictionary in Typescript

Apparently this doesn't work when passing the ...READ MORE

answered May 31, 2022 in TypeSript by Nina
• 3,060 points
6,539 views
0 votes
1 answer
0 votes
1 answer

How to use moment.js library in angular 2 typescript app?

REFERENCE: https://momentjs.com/docs/#/use-it/typescript/ You can install this by using: npm install ...READ MORE

answered Jun 1, 2022 in TypeSript by Nina
• 3,060 points
1,693 views
0 votes
1 answer

How to create enum type in TypeScript?

TypeScript 0.9+ has a specification for enums: enum ...READ MORE

answered Jun 8, 2022 in TypeSript by Nina
• 3,060 points
1,061 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,772 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,187 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,263 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,901 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP