Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 量角器-MacOS-语法错误:意外标记';出口';_Node.js_Visual Studio Code_Jasmine_Protractor - Fatal编程技术网

Node.js 量角器-MacOS-语法错误:意外标记';出口';

Node.js 量角器-MacOS-语法错误:意外标记';出口';,node.js,visual-studio-code,jasmine,protractor,Node.js,Visual Studio Code,Jasmine,Protractor,大家好:量角器有些问题 我是一个新尝试在Mac中用VSCode配置量角器的人(在Eclipse中我无法做到这一点,这真的很难做到) 我从一开始就用量角器创建一个项目 我已经创建了一个conf.js文件: export const config = { framework: 'jasmine2', specs: ['specs/*.spec.js'], onPrepare: function(){ // Getting CLI report co

大家好:量角器有些问题

我是一个新尝试在Mac中用VSCode配置量角器的人(在Eclipse中我无法做到这一点,这真的很难做到) 我从一开始就用量角器创建一个项目

我已经创建了一个conf.js文件:

export const config = {
    framework: 'jasmine2',
    specs: ['specs/*.spec.js'],
    onPrepare: function(){
    // Getting CLI report
          const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
          jasmine.getEnv().addReporter(new SpecReporter({
          spec: {
            displayStacktrace: true
          }
        }));
    //Getting XML report
        var jasmineReporters = require('jasmine-reporters');
        jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
           consolidateAll: true,
           filePrefix: 'guitest-xmloutput',
           savePath: '.'
        }));
    //Getting screenshots
      var fs = require('fs-extra');
        fs.emptyDir('screenshots/', function (err) {
                 console.log(err);
             });
             jasmine.getEnv().addReporter({
                 specDone: function(result) {
                     if (result.status == 'failed') {
                         browser.getCapabilities().then(function (caps) {
                             var browserName = caps.get('browserName');
                             browser.takeScreenshot().then(function (png) {
                                 var stream = fs.createWriteStream('screenshots/' + browserName + '-' + result.fullName+ '.png');
                                 stream.write(new Buffer.from(png, 'base64'));
                                 stream.end();
                             });
                         });
                     }
                 }
             });
    },
      onComplete: function() {
    //Getting HTML report
    var browserName, browserVersion;
         var capsPromise = browser.getCapabilities();
         capsPromise.then(function (caps) {
            browserName = caps.get('browserName');
            browserVersion = caps.get('version');
            platform = caps.get('platform');
            var HTMLReport = require('protractor-html-reporter-2');
            testConfig = {
                reportTitle: 'Protractor Test Execution Report',
                outputPath: './',
                outputFilename: 'ProtractorTestReport',
                screenshotPath: './screenshots',
                testBrowser: browserName,
                browserVersion: browserVersion,
                modifiedSuiteName: false,
                screenshotsOnlyOnFailure: true,
                testPlatform: platform
            };
            new HTMLReport().from('guitest-xmloutput.xml', testConfig);
        });
      }
}
这是我的json文件:

 {
  "name": "protractor_initium",
  "version": "1.0.0",
  "description": "Final Protractor Framework",
  "allowJs": true,
  "main": "conf.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Rodrigo González",
  "license": "ISC",
  "dependencies": {
    "@types/jasmine": "^3.5.0",
    "@types/node": "^12.12.14",
    "fs-extra": "^8.1.0",
    "jasmine": "^3.5.0",
    "jasmine-spec-reporter": "^4.2.1",
    "protractor": "^5.4.2",
    "protractor-html-reporter-2": "^1.0.4",
    "ts-node": "^8.5.4",
    "typescript": "^3.7.2"
  },
  "devDependencies": {
    "@babel/preset-env": "^7.7.4",
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "jasmine-reporters": "^2.3.2"
  }
}
我的巴别塔档案:

    newFunction()

function newFunction() {
  {
    "presets";
    ["@babel/preset-env"];
  }
}
我安装的软件:

npm: 6.12.1
node: v13.1.0
Protractor: 5.4.2
Java:. openjdk version "13.0.1" 2019-10-15
OpenJDK Runtime Environment (build 13.0.1+9)
OpenJDK 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)
运行dragor conf.js后,我遇到了下一个问题:

[14:53:01] E/configParser - Error code: 105
[14:53:01] E/configParser - Error message: failed loading configuration file conf.js
[14:53:01] E/configParser - /Users/rodrigo.g/Documents/VS_Workspace/Protractor_Initium/conf.js:1
export const config = {
^^^^^^

SyntaxError: Unexpected token 'export'
    at wrapSafe (internal/modules/cjs/loader.js:1043:16)
    at Module._compile (internal/modules/cjs/loader.js:1091:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
    at Module.load (internal/modules/cjs/loader.js:976:32)
    at Function.Module._load (internal/modules/cjs/loader.js:884:14)
    at Module.require (internal/modules/cjs/loader.js:1016:19)
    at require (internal/modules/cjs/helpers.js:69:18)
    at ConfigParser.addFileConfig (/usr/local/lib/node_modules/protractor/built/configParser.js:135:26)
    at Object.initFn [as init] (/usr/local/lib/node_modules/protractor/built/launcher.js:93:22)
    at Object.<anonymous> (/usr/local/lib/node_modules/protractor/built/cli.js:226:10)
[14:53:01]E/configParser-错误代码:105
[14:53:01]E/configParser-错误消息:加载配置文件conf.js失败
[14:53:01]E/configParser-/Users/rodrigo.g/Documents/VS_Workspace/dragrator_Initium/conf.js:1
导出常量配置={
^^^^^^
SyntaxError:意外标记“导出”
在wrapSafe(内部/modules/cjs/loader.js:1043:16)
at模块编译(内部/modules/cjs/loader.js:1091:27)
在Object.Module._extensions..js(internal/modules/cjs/loader.js:1160:10)
在Module.load(内部/modules/cjs/loader.js:976:32)
at Function.Module._load(内部/modules/cjs/loader.js:884:14)
at Module.require(内部/modules/cjs/loader.js:1016:19)
根据需要(内部/modules/cjs/helpers.js:69:18)
在ConfigParser.addFileConfig(/usr/local/lib/node\u modules/dragrator/build/ConfigParser.js:135:26)
在Object.initFn[as init](/usr/local/lib/node_modules/dragrator/build/launcher.js:93:22)
at对象。(/usr/local/lib/node_modules/dragrator/build/cli.js:226:10)

有人能帮我吗?

错误是直截了当的

您的conf.js的第一行应该是

exports.config = {
对于javascript,或

export interface Config {

对于typescript

我已经更改了exports.config={但是有一个弹出窗口说文件是一个CommonJS模块;它可能会转换为ES6模块。(ts 80001)