protractor icon indicating copy to clipboard operation
protractor copied to clipboard

npm run e2e fails to compile typescript

Open keslavi opened this issue 10 years ago • 4 comments

I installed vulgar as per instructions.
npm run e2e causes the error "failed to compile typescript". the website itself does run as expected.

  • Node Version: 5.7.1
  • Protractor Version: 4.0.0
  • Browser(s): Chrome
  • Operating System and Version: OS X El Capitan 10.11.5
  • Your protractor configuration file
// @datatype_void
require('ts-node/register');

exports.config = {
  baseUrl: 'http://localhost:3000/',

  // use `npm run e2e`
  specs: [
    'src/**/**.e2e.ts',
    'src/**/*.e2e.ts'
  ],
  exclude: [],

  framework: 'jasmine2',

  allScriptsTimeout: 110000,

  jasmineNodeOpts: {
    showTiming: true,
    showColors: true,
    isVerbose: false,
    includeStackTrace: false,
    defaultTimeoutInterval: 400000
  },
  directConnect: true,

  capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
      'args': ['show-fps-counter=true']
    }
  },

  onPrepare: function() {
    browser.ignoreSynchronization = true;
  },

  /**
   * Angular 2 configuration
   *
   * useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching
   * `rootEl`
   *
   */
   useAllAngular2AppRoots: true
};
  • A relevant example test install vulgar as per directions on github. try to start protractor

    npm run e2e

  • Output from running the test

> [email protected] protractor /data/dev/20160709/rpVulgar
> protractor

[19:20:14] I/direct - Using ChromeDriver directly...
[19:20:14] I/launcher - Running 1 instances of WebDriver
[19:21:27] E/launcher - Error: TSError: ⨯ Unable to compile TypeScript
node_modules/@angular/common/esm/src/directives/ng_for.d.ts (7,5): Duplicate identifier 'readonly'. (2300)
  • Steps to reproduce the bug

install vulgar using directions on github.

npm start (new terminal window) gulp serve
(new terminal window) npm run e2e

"unable to compile typescript" followed by many lines of similar errors.

keslavi avatar Jul 13 '16 02:07 keslavi

Looking at https://github.com/datatypevoid/vulgar/blob/master/config/protractor.conf.js in the vulgar project, it is assuming that the specs are in TypeScript. This appears to be an issue with their project and not Protractor. Protractor requires TypeScript to be transpiled to JavaScript. See https://github.com/angular/protractor/blob/master/exampleTypescript/conf.ts#L18.

cnishina avatar Jul 13 '16 03:07 cnishina

you've identified the problem, but I'm not sure how to resolve the issue. did someone run the protractor tests as is in the vulgar project before releasing? if so, what was the command sequence?

keslavi avatar Jul 13 '16 12:07 keslavi

@keslavi, You need to run following commands:

// To transpile the typescript to javascript.
npm run tsc

// Then need to run transpiled protractor.conf.js file
npm run e2e

anilreddy avatar Jul 13 '16 12:07 anilreddy

I have the same problem, I run node_modules/protractor/bin/webdriver-manager start fallowing this tutorial: https://www.javascripttuts.com/e2e-testing-javascript-zero-hero-part-1/ but have this response:

image

the error menssage says: E/launcher - Error: TSError: ⨯ Unable to compile TypeScript

This is my package.json:

{
  "name": "",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "cd app && nyc mocha",
    "build": "ng build",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "dependencies": {
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4",
    "body-parser": "^1.15.1",
    "config": "^1.20.1",
    "express": "^4.13.4",
    "mongoose": "^4.4.15",
    "morgan": "^1.7.0"
  },
  "devDependencies": {
    "@angular/cli": "1.1.0",
    "@angular/compiler-cli": "^4.1.3",
    "@types/jasmine": "^2.5.51",
    "codelyzer": "~3.0.1",
    "jasmine-core": "2.6.2",
    "jasmine-spec-reporter": "4.1.0",
    "karma": "1.7.0",
    "karma-chrome-launcher": "^2.1.1",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.1.0",
    "karma-remap-istanbul": "^0.6.0",
    "protractor": "5.1.2",p
    "ts-node": "3.0.4",
    "tslint": "5.4.2",
    "typescript": "2.3.4",
    "chai": "^3.5.0",
    "chai-http": "^2.0.1",
    "istanbul": "^0.4.5",
    "mocha": "^2.4.5",
    "nyc": "^11.0.2"
  }
}

and here is my tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ]
  }
}

ronaiza-cardoso avatar Jun 09 '17 03:06 ronaiza-cardoso