在Jenkins上运行时cumcum-js解析错误 [英] cucumber-js parse error when run on Jenkins

查看:289
本文介绍了在Jenkins上运行时cumcum-js解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图设置一个jenkins管道步骤以使用cucumber-js运行一些测试方案,但是我从构建中得到一个错误,如下所示:

I am trying to setup a jenkins pipeline step to runs some test scenarios using cucumber-js but I am getting an error back from the build as follows:

Error: Parse error in 'e2e/definitions/login.js': (1:1): expected:
#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'const { Given, When, Then } = require('cucumber');'

在管道步骤中运行的命令如下:

The command being run in the pipeline step is as follows:

cucumber-js e2e/features/**/*.feature --require e2e/**/*.js

错误所引用的login.js文件的开头行是:

The opening lines of the login.js file the error is referencing are:

const { Given, When, Then } = require('cucumber');
const { Selector } = require('testcafe');

我想知道这是否与nodejs版本差异有关,因为我在计算机上运行8.11.2并没有看到这些错误,因此在Jenkins上我们正在运行10.5.0

I'm wondering if this has something to do with nodejs version differences, as I am running 8.11.2 on my machine and dont see these errors, on Jenkins we are running 10.5.0

有人知道问题出在哪里吗,请向我指出正确的方向吗?

Does anyone know what the problem could be and point me in the right direction please?

谢谢

推荐答案

您可能会遇到此问题,因为在--require模式之后指定的全局模式不会解析为真实文件名,但是在您的Jenkins上会解决.尝试将e2e/**/*.js用双引号引起来: cucumber-js e2e/features/**/*.feature --require "e2e/**/*.js"

Likely you have this problem because the glob pattern specified after the --require pattern isn't resolved to real file names, but on your Jenkins it does. Try to wrap e2e/**/*.js in double quotes: cucumber-js e2e/features/**/*.feature --require "e2e/**/*.js"

这篇关于在Jenkins上运行时cumcum-js解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆