Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier way to specify path of custom parser #85

Closed
epgremill3 opened this issue Feb 9, 2018 · 5 comments
Closed

Easier way to specify path of custom parser #85

epgremill3 opened this issue Feb 9, 2018 · 5 comments

Comments

@epgremill3
Copy link

Hello,
I just started using protractor-flake today and I'm really liking it so far - thanks!

There's one thing I've run into that I had to work around - the custom parser path seems to use require.resolve which seems to use __dirname or equivalent to look for the file. However, I've installed protractor and protractor-flake globally, so I'm running my tests from a different directory than where protractor-flake is installed.

I did some quick tests tweaking the source and in parsers/index.js handlePath function if I do something like:

var path = require('path');
var calledFrom = path.resolve('./');
var myCustomParserPath = calledFrom + parserPath;
return require(myCustomParserPath);

Then it works for me. Maybe you could nest that (or some nicer equivalent) in the catch block to support relative paths from the calling directory?

Alternatively, maybe there's a better way for me to achieve this? For now I'm specifying my custom parser path on the command line with %CD%\subdirectory\parser.js which works due to expansion before being passed in...

Thanks for considering and keep up the good work.

  • Operating system and version: Windows 7 (64-bit)
  • Node.js version: 8.9.4
  • Protractor version: 5.3.0
  • Protractor flake version: 3.0.1
  • Protractor configuration file: N/A
  • Output from your test suite:
C:\nvm\v8.9.4\node_modules\protractor-flake\dist\parsers\index.js:38
    throw new Error('Invalid Custom Parser Path Specified: ' + parserPath);
    ^

Error: Invalid Custom Parser Path Specified: helpers\parser.js
    at handlePath (C:\nvm\v8.9.4\node_modules\protractor-flake\dist\parsers\index.js:38:11)
    at getParser (C:\nvm\v8.9.4\node_modules\protractor-flake\dist\parsers\index.js:58:12)
    at exports.default (C:\nvm\v8.9.4\node_modules\protractor-flake\dist\index.js:42:39)
    at Object.<anonymous> (C:\nvm\v8.9.4\node_modules\protractor-flake\bin\protractor-flake:17:1)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
@NickTomlin
Copy link
Owner

Ah yep this looks like a bug. Thanks for reporting! I'm not on windows but I can replicate on OSX with a relative path.

I'll try to get a fix out tomorrow but it may take until next week. Feel free to submit a PR if you have a fix of your own!

NickTomlin added a commit that referenced this issue Feb 10, 2018
@NickTomlin
Copy link
Owner

I have a potential fix for this in 874a08e would you mind trying that out? I don't have a windows machine so there could be something that doesn't work there.

Thanks!

@epgremill3
Copy link
Author

Gladly! I'll try to get to it this weekend. If not, then on Monday for sure. I'll report back as soon as I've tried it. Thanks!

@epgremill3
Copy link
Author

All right - I tested and can confirm that all of the following work:

  • Absolute path e.g. C:\path\to\mycustomparser.js
  • Relative path with no leading modifier e.g. to\mycustomparser.js
  • Relative path starting with ./ e.g. ./to/mycustomparser.js
  • Relative path starting with ..\ e.g. ..\path\to\mycustomparser.js

I think it looks good - thanks!

@NickTomlin
Copy link
Owner

NickTomlin commented Feb 14, 2018

This has been published to NPM as 3.0.2. Thanks for reporting the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants