【问题标题】:CucumberJS not compiling in typescript in Gitlab CICucumberJS 没有在 Gitlab CI 的打字稿中编译
【发布时间】:2020-07-19 08:49:45
【问题描述】:

NPM 脚本"cucumber": "cucumber-js --require features/tests.setup.js --require features/**/*.ts".

tests.setup.js

require('ts-node').register({
  transpileOnly: true,
  compilerOptions: {
    "module": "commonjs",
  },
});

Gitlab CI 错误

> cucumber-js --require features/tests.setup.js --require features/**/*.ts
Error: Parse error in 'features/step-definitions/steps.calculus-triangle.ts': (1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'import {Then} from 'cucumber''
    at events.forEach.event (/builds/Ambroise-Rabier/mandala-vibratoire/node_modules/cucumber/lib/cli/helpers.js:110:13)
    at Array.forEach (<anonymous>)
    at getTestCases (/builds/Ambroise-Rabier/mandala-vibratoire/node_modules/cucumber/lib/cli/helpers.js:81:10)
    at _bluebird.default.each (/builds/Ambroise-Rabier/mandala-vibratoire/node_modules/cucumber/lib/cli/helpers.js:58:35)

它在本地工作(win 10),但在 Gitlab CI 上它似乎忽略了打字稿编译。

【问题讨论】:

    标签: typescript gitlab-ci cucumberjs


    【解决方案1】:

    我在Error running ./node_modules/.bin/cucumber-js in GitLab CI 的帮助下找到了一些有用的东西,但是我没有使用nyc,所以这里只使用 cucumberjs 的解决方案。

    NPM 脚本"cucumber": "cucumber-js --profile default".

    创建 cucumber.js 包含内容的项目根目录:

    let common = [
      '--require features/tests.setup.js',
      '--require features/**/*.ts',
    ].join(' ');
    
    module.exports = {
      default: common,
    };
    

    相关文档https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#profiles

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-19
      • 2020-04-07
      • 2019-05-08
      • 2016-11-11
      • 2018-02-18
      • 2015-12-17
      • 2018-07-03
      相关资源
      最近更新 更多