【问题标题】:Error in index.d.ts file in node_modules/@types/chai foldernode_modules/@types/chai 文件夹中的 index.d.ts 文件出错
【发布时间】:2020-02-16 09:19:32
【问题描述】:

在运行“npm run am:remote:dev”命令时出现以下错误。从 912 到 1916 的行中显示错误。

node_modules/@types/chai/index.d.ts(1879,43): error TS1005: ',' expected.
node_modules/@types/chai/index.d.ts(1879,56): error TS1005: ',' expected.
node_modules/@types/chai/index.d.ts(1879,71): error TS1005: ',' expected.
node_modules/@types/chai/index.d.ts(1879,86): error TS1109: Expression expected

尝试删除节点模块文件夹并再次安装 npm。尝试卸载所有应用程序并再次完全重新安装它们。错误仍然存​​在。这是一个用黄瓜写的自动化脚本,量角器使用打字稿。

PFB 具有运行配置的远程配置文件:

// tslint:disable:max-line-length
// tslint:disable:no-console
import { browser, Config } from 'protractor';
import capabilitiesConfig from '../capabilities';
const jsonReports = process.cwd() + '/reports/json';
const browserStack = require('browserstack-local');

export const config: Config = {

  multiCapabilities: [
    capabilitiesConfig['chrome-windows10'],
    capabilitiesConfig['chrome-windows7'],
    capabilitiesConfig['firefox-high-sierra'],
    capabilitiesConfig['firefox-windows10'],
    capabilitiesConfig['firefox-windows7'],
    capabilitiesConfig['google-pixel3'],
    capabilitiesConfig['iphone8-plus'],
    capabilitiesConfig.iphonex,
    capabilitiesConfig['samsung-galaxy-s7'],
    capabilitiesConfig['samsung-galaxy-s8'],
  ],
  allScriptsTimeout: 60000,
  // to connect directly to the browser Drivers. Only available for Firefox and Chrome. Use if no browserstack credentials
  directConnect: false,
  // Browserstack credentials
  browserstackUser: 'dbxadminuser1',
  browserstackKey: '6s257AhmKXh6f4q9AHpi',

  framework: 'custom',
  frameworkPath: require.resolve('protractor-cucumber-framework'),

  specs: [
    // Login
    // makes sure login runs first
    '../../../tests/am/features/login/login.feature', 

    // Profile
    '../../../tests/am/features/profile/profileUI.feature',

    // Logout
    '../../../tests/am/features/logout/logout.feature'
  ],

  // runs before preparing the testing environment. This particular function connects to the Browserstack servers
  beforeLaunch: () => {
      console.log('Connecting local');
      return new Promise((resolve: any, reject: any) => {
          exports.bs_local = new browserStack.Local();
          exports.bs_local.start({ key: exports.config.browserstackKey }, (error: any) => {
              if (error) { return reject(error); }
              console.log('Connected. Now testing...');

              resolve();
          });
      });
  },

  // runs after all tests have finished running. This stops the Browserstack server
  afterLaunch: () => {
      return new Promise((resolve: any, reject: any) => {
          exports.bs_local.stop(resolve);
      });
  },

  onPrepare: () => {
        browser.waitForAngularEnabled(false);
        // Reporter.createDirectory(jsonReports);
        browser.getProcessedConfig().then((processedConfig: any) => {
            browser.params.login = {
                username: processedConfig.capabilities.username,
                password: process.env.BS_PASSWORD,
            };
        });
  },
  plugins: [{
        package: 'protractor-multiple-cucumber-html-reporter-plugin',
        options: {
            automaticallyGenerateReport: true,
        },
    }],
  params: {
      env: 'local',
      login: {
        username: '',
        password: '',
      },
      application: 'am',
  },

  cucumberOpts: {
    compiler: 'ts:ts-node/register',
    format: 'json:.tmp/am/results.json',
    require: [
      '../../tests/shared/features/*/*.step.js',
      '../../tests/am/features/*/*.step.js',
    ],
    strict: true,
  },
};

运行该命令后,将打开一个记录应用程序的 browserstack 实例。


PFB package.json 文件供参考。

{
  "name": "rockwell-automation-tests",
  "version": "1.0.0",
  "license": "MIT",
  "description": "",
  "author": "",
  "repository": "https://github.com/SolsticeConsulting/rockwell-testing",
  "scripts": {
    "tag": "tsc && protractor typeScript/config/my/local.config.js --cucumberOpts.tags=$TAG --params.env=$ROK_ENV",
    "remote-tag": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags=$TAG --params.env=$ROK_ENV",
    "build": "tsc",
    "clean": "rimraf typeScript/",
    "clean-build": "npm run clean && npm run build",
    "am:debug": "tsc && node --inspect-brk node_modules/protractor/bin/protractor typeScript/config/am/local.config.js",
    "am:remote:dev": "tsc && protractor typeScript/config/am/remote.config.js --params.env=dev",
    "am:remote:uat": "tsc && protractor typeScript/config/am/remote.config.js --params.env=uat",
    "am:remote:devqa": "tsc && protractor typeScript/config/am/remote.config.js --params.env=devqa",
    "am:remote:uatqa": "tsc && protractor typeScript/config/am/remote.config.js --params.env=uatqa",
    "am:remote:raqa": "tsc && protractor typeScript/config/am/remote.config.js --params.env=raqa",
    "my:debug": "tsc && node --inspect-brk node_modules/protractor/bin/protractor typeScript/config/my/local.config.js",
    "my:local": "tsc && protractor typeScript/config/my/local.config.js",
    "am:local": "tsc && protractor typeScript/config/am/local.config.js",
    "my:remote:dev": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Smoke' --params.env=dev",
    "my:remote:devqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Smoke' --params.env=devqa",
    "my:remote:uat": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Smoke' --params.env=uat",
    "my:remote:uatqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Smoke' --params.env=uatqa",
    "my:remote:raqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Smoke' --params.env=raqa",
    "my:remote:prod": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Smoke' --params.env=prod",
    "my:remote:bom:dev": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Bom' --params.env=dev",
    "my:remote:bom:devqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Bom' --params.env=qa",
    "my:remote:bom:uat": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Bom' --params.env=uat",
    "my:remote:bomorders:dev": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@BOMOrders' --params.env=dev",
    "my:remote:bomorders:devqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@BOMOrders' --params.env=qa",
    "my:remote:bomorders:uat": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@BOMOrders' --params.env=uat",
    "my:remote:bomorders:uatqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@BOMOrders' --params.env=uatqa",
    "my:remote:repairs:dev": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Repairs' --params.env=dev",
    "my:remote:repairs:test": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Repairs' --params.env=test",
    "my:remote:repairs:testqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Repairs' --params.env=testqa",
    "my:remote:repairs:uat": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Repairs' --params.env=uat",
    "my:remote:repairs:uatqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Repairs' --params.env=uatqa",
    "my:remote:repairs:prod": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Repairs' --params.env=prod",
    "my:remote:equipment:dev": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@MyEquipment' --params.env=dev",
    "my:remote:equipment:devqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@MyEquipment' --params.env=devqa",
    "my:remote:powerbi:dev": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@PowerBI' --params.env=dev",
    "my:remote:powerbi:devqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@PowerBI' --params.env=devqa",
    "my:remote:powerbi:uat": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@PowerBI' --params.env=uat",
    "my:remote:powerbi:uatqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@PowerBI' --params.env=uatqa",
    "my:remote:powerbi:prod": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@PowerBI' --params.env=prod",
    "my:remote:equipment:prod": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@MyEquipment' --params.env=prod",
    "my:remote:services:dev": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@Services' --params.env=dev",
    "my:remote:csm:devqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@CSM' --params.env=devqa",
    "my:remote:csm:dev": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@CSM' --params.env=dev",
    "my:remote:csm:uat": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@CSM' --params.env=uat",
    "my:remote:csm:uatqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@CSM' --params.env=uatqa",
    "my:remote:csm:prod": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@CSM' --params.env=prod",
    "my:remote:product-availability:devqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@ProductAvailability' --params.env=devqa",
    "my:remote:product-availability:dev": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@ProductAvailability' --params.env=dev",
    "my:remote:product-availability:uat": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@ProductAvailability' --params.env=uat",
    "my:remote:product-availability:uatqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@ProductAvailability' --params.env=uatqa",
    "my:remote:product-availability:prod": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@ProductAvailability' --params.env=prod",
    "my:remote:security:uatqa": "tsc && protractor typeScript/config/my/remote.config.js --cucumberOpts.tags='@BOMSecurity' --params.env=uatqa",
    "webdriver-update": "webdriver-manager update",
    "webdriver-start": "webdriver-manager start"
  },
  "devDependencies": {
    "@types/chai": "^4.1.3",
    "@types/chai-as-promised": "^7.1.0",
    "@types/cucumber": "^4.0.4",
    "@types/node": "8.9.4",
    "@types/selenium-webdriver": "3.0.8",
    "browserstack-local": "^1.3.7",
    "browserstack-webdriver": "2.41.1",
    "chai": "4.1.2",
    "chai-as-promised": "7.1.1",
    "cucumber": "4.0.0",
    "cucumber-html-reporter": "^4.0.4",
    "mkdirp": "^0.5.1",
    "protractor": "^5.4.1",
    "protractor-cucumber-framework": "5.0.0",
    "protractor-multiple-cucumber-html-reporter-plugin": "1.7.0",
    "rimraf": "^2.6.2",
    "ts-node": "5.0.0",
    "typescript": "2.7.2",
    "webdriver-manager": "12.1.7",
    "tslint": "^5.18.0"
  },
  "dependencies": {
    "@types/protractor": "^4.0.0",
    "@types/uuid": "^3.4.4"
  }
}

【问题讨论】:

  • 你好,可以粘贴 package.json 吗?
  • 嗨 Frecia,已添加 package.json 文件。
  • 谢谢,你运行的是什么 tsc 版本?
  • TSC 版本 3.6.4,Node 版本 10.16.3,非版本 6.9.0,VSCode 1.39.2

标签: typescript npm visual-studio-code


【解决方案1】:

我遇到了同样的问题,并通过将 typescript2.3.4 升级到 3.7.2 来修复它。

提交:https://github.com/Jeff-Tian/ali-mns/commit/28c07d27f568bea56143bec4ab3c96ac130bbcc5#diff-b9cfc7f2cdf78a7f4b91a753d10865a2

该提交的构建历史记录:https://travis-ci.com/Jeff-Tian/ali-mns/builds/135875304

【讨论】:

  • 杰夫,感谢您的解决方案。我能够通过不同的步骤解决问题。我的项目与 git 连接有一些错误,这就是错误来的问题,我能够通过重新建立 git 来解决。
猜你喜欢
  • 2018-11-28
  • 2019-07-05
  • 2017-07-08
  • 1970-01-01
  • 2019-02-25
  • 2022-12-16
  • 2022-12-15
  • 1970-01-01
  • 2017-04-13
相关资源
最近更新 更多