Protractor: Duplicate identifier error

Created on 5 Dec 2016  路  4Comments  路  Source: angular/protractor

  • Node Version: 6.9.1
  • Protractor Version: 4.0.11
  • Angular Version: 2.1.2
  • Operating System and Version chrome, ubuntu 16 LTS
  • Your protractor configuration file
exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['./protractor/**-spec.js'],

    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome'
    },

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true
    }
};

Shouldn't https://github.com/angular/protractor/blob/master/package.json#L15 be declared as a dev dependency?
Opened up this bug after submitting: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/13064

I've started a new angular2 project and included the following dev dependency:
"@types/mocha": "2.2.33",

It installs correctly however when I run:
webpack --config webpack.config.dev.js --progress --profile --watch

I get:

[at-loader] node_modules/@types/jasmine/index.d.ts:15:18 
    Duplicate identifier 'xit'. 

[at-loader] node_modules/@types/mocha/index.d.ts:33:13 
    Duplicate identifier 'describe'. 

[at-loader] node_modules/@types/mocha/index.d.ts:34:13 
    Duplicate identifier 'xdescribe'. 

[at-loader] node_modules/@types/mocha/index.d.ts:39:13 
    Duplicate identifier 'it'. 

[at-loader] node_modules/@types/mocha/index.d.ts:40:13 
    Duplicate identifier 'xit'. 

My webpack config file:

var webpack = require('webpack');

module.exports = {
    devtool: 'cheap-module-eval-source-map',

    output: {
        path: './public/js/app',
        publicPath: "/js/app/",
        filename: 'bundle.js',
        chunkFilename: '[id].chunk.js'
    },
    entry: {
        'app': './assets/app/main.polymer.ts'
    },

    resolve: {
        extensions: ['.js', '.ts']
    },

    module: {
        loaders: [
            {
                test: /\.ts$/,
                loaders: [
                    'awesome-typescript-loader',
                    'angular2-template-loader',
                    'angular2-router-loader'
                ]
            },
            {
                test: /\.html$/,
                loader: 'html'
            },
            {
                test: /\.css$/,
                loader: 'raw'
            }
        ]
    },

    plugins: [
        new webpack.ContextReplacementPlugin(
            // The (\\|\/) piece accounts for path separators in *nix and Windows
            /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
            './src' // location of your src
        )
    ]
};

Same thing happens with @types/jasmine:
Just found out that the errors:

[at-loader] node_modules/@types/jasmine/index.d.ts:9:18 
    Duplicate identifier 'describe'. 

[at-loader] node_modules/@types/jasmine/index.d.ts:11:18 
    Duplicate identifier 'xdescribe'. 

[at-loader] node_modules/@types/jasmine/index.d.ts:13:18 
    Duplicate identifier 'it'. 

[at-loader] node_modules/@types/jasmine/index.d.ts:15:18 
    Duplicate identifier 'xit'. 

Apparently this happens when I write my tests with mocha and use protractor for e2e tests.

bug

Most helpful comment

Since this is a potential breaking change to existing jasmine users, I've opened PR #3795 to fix this in the upcoming release for selenium3 in the beta branch. This specific package does not require import {it} from 'jasmine' similarly to how the the mocha typings are written. This is a good idea to move this out.

We still use q types in plugins and I believe that should be included until we eventually remove q. Also, we export some @types/selenium-webdriver under the Protractor typings so that should be maintained.

A work around would be to set your types array in your tsconfig and to not include jasmine type:

{
   "compilerOptions": {
       "types" : ["node", "lodash", "express"]
   }
}

This tsconfig.json file will only include ./node_modules/@types/node, ./node_modules/@types/lodash and ./node_modules/@types/express. Other packages under node_modules/@types/* will not be included.

from https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

All 4 comments

Yup, we'll change this. Thanks for reporting it.

@cnishina created pull request https://github.com/angular/protractor/pull/3793

Since this is a potential breaking change to existing jasmine users, I've opened PR #3795 to fix this in the upcoming release for selenium3 in the beta branch. This specific package does not require import {it} from 'jasmine' similarly to how the the mocha typings are written. This is a good idea to move this out.

We still use q types in plugins and I believe that should be included until we eventually remove q. Also, we export some @types/selenium-webdriver under the Protractor typings so that should be maintained.

A work around would be to set your types array in your tsconfig and to not include jasmine type:

{
   "compilerOptions": {
       "types" : ["node", "lodash", "express"]
   }
}

This tsconfig.json file will only include ./node_modules/@types/node, ./node_modules/@types/lodash and ./node_modules/@types/express. Other packages under node_modules/@types/* will not be included.

from https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

Was this page helpful?
0 / 5 - 0 ratings