我有一个正在尝试用cumingjs测试的类。当我从功能导入类时,当我运行Cucumberjs时,它会为我提供以下信息]
我执行的命令
./node_modules/.bin/cucumber-js ./tests/features
我得到的错误
getAll = () => this.data; ^ SyntaxError: Unexpected token = at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) : : :
文件
// TestApi.js
class TestApi {
constructor(){
this.data = ['teststuff', 'teststuff2']
}
getAll = () => this.data;
}
//test.feature
const { Before, Given, When, Then } = require('cucumber')
const { TestApi } = require('../../../api/TestApi.js');
const { TestDomain } = require('../../../domain/domain.js');
我有一个正在尝试用cumingjs测试的类。当我从功能导入类时,当我运行Cucumberjs命令时,它会为我提供以下信息:./node_modules/.bin/cucumber-js。/ ...
问题与CucumberJS无关,而与计算机上的NodeJS版本有关。您可以通过在终端中运行node -v
命令来检查当前版本。如果您的版本早于NodeJS website上当前列出的LTS版本,请按照安装说明进行操作。