Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor error 105 when trying to run spec.js

Tags:

protractor

my protractor was working fine and when updated it it couldnt open a simple spec file it always gives thsi error. I searched for a solution but couldnt find one the conf and spec files are samples from the protractor site itself im pasting the error below hope you could help. Thanks in advance

conf.js error

[09:10:06] E/configParser - error code: 105
[09:10:06] E/configParser - description: failed loading configuration file spec.js

C:\Users\y\AppData\Roaming\npm\node_modules\protractor\built\configParser.js:130

throw new exitCodes_1.ConfigError(logger, 'failed loading configurat
ion file ' + filename);
            ^
Error
    at ConfigError.ProtractorError (C:\Users\y\AppData\Roaming\npm\node_modules\protractor\built\exitCodes.js:10:22)
    at new ConfigError (C:\Users\y\AppData\Roaming\npm\node_modules\protractor\built\exitCodes.js:26:16)
    at ConfigParser.addFileConfig (C:\Users\y\AppData\Roaming\npm\node_modules\protractor\built\configParser.js:130:19)
    at Object.initFn [as init] (C:\Users\y\AppData\Roaming\npm\node_modules\protractor\built\launcher.js:94:22)
    at Object.<anonymous> (C:\Users\y\AppData\Roaming\npm\node_modules\protractor\built\cli.js:130:10)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)

The conf and spec files are the sample ones from the site

conf.js:

exports.config = {
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js']
}

spec.js

describe('Protractor Demo App', function() {
  it('should have a title', function() {
    browser.get('http://juliemr.github.io/protractor-demo/');

    expect(browser.getTitle()).toEqual('Super Calculator');
  });
});
like image 597
Anonymous Avatar asked May 03 '16 09:05

Anonymous


3 Answers

Per @jtzero's remark, the issue lies with the configuration parser masking the actual error message when loading the configuration file.

Depending on whether you run Protractor as global or from the folder, open up (C:\Users\y\AppData\Roaming\npm\)node_modules\protractor\built\configParser.js at line 13‌​0. There you can add logger.error(e); e.g:

    /**
     * Public function specialized towards merging in a file's config
     *
     * @public
     * @param {String} filename
     */
    ConfigParser.prototype.addFileConfig = function (filename) {
        if (!filename) {
            return this;
        }
        var filePath = path.resolve(process.cwd(), filename);
        var fileConfig;
        try {
            fileConfig = require(filePath).config;
        }
        catch (e) {
            logger.error(e);
            throw new exitCodes_1.ConfigError(logger, 'failed loading configuration file ' + filename);
        }
        if (!fileConfig) {
            throw new exitCodes_1.ConfigError(logger, 'configuration file ' + filename + ' did not export a config object');
        }
        fileConfig.configDir = path.dirname(filePath);
        this.addConfig_(fileConfig, fileConfig.configDir);
        return this;
    };

This will then report the error in the output. In my case it was a failing call to require():

[10:36:29] E/configParser - { [Error: Cannot find module 'phantomjs'] code: 'MODULE_NOT_FOUND' }

Repored GitHub issue #3301: https://github.com/angular/protractor/issues/3301

Update
Protractor 4.0 will include a fix for this problem to report the masked error message with a stack trace.

like image 131
Bart Verkoeijen Avatar answered Nov 19 '22 22:11

Bart Verkoeijen


You should be running the conf.js file, not the spec.js file.

It looks like you are running the command "protractor spec.js" when it should be "protractor conf.js". The error says it is looking for a configuration file but you are passing it a spec file.

like image 3
kgoodman Avatar answered Nov 19 '22 21:11

kgoodman


Passing correct path to conf.js file can be a solution. Try to navigate to folder, in which you have this file and then launch the command again.

Of course, point at conf.js file, not spec.

like image 2
Teukros Avatar answered Nov 19 '22 21:11

Teukros