I'm in the process of setting up a WebdriverIO project using TypeScript and Cucumber. I followed the steps provided by the wizard, which was pretty straightforward. I opted for Cucumber, TypeScript, and the page object model.
This setup created a test/wdio.conf.ts
file, a test/tsconfig.json
file, along with a basic Feature file template.
However, when I try to run the test using the command wdio run test/wdio.conf.ts
,
I encounter the following error:
export const config = {
^^^^^^
SyntaxError: Unexpected token 'export'
What could be causing this issue?
test/wdio.conf.ts
export const config = {
// ...
autoCompileOpts: {
autoCompile: true,
// Refer to 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
// 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"
}
}