Skip to content

Commit

Permalink
Fix E2E tests adding missing webdriver
Browse files Browse the repository at this point in the history
  • Loading branch information
jpetitcolas committed Nov 30, 2016
1 parent b98f5b3 commit 9a845e4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

install:
npm install
./node_modules/protractor/bin/webdriver-manager update --versions.chrome=2.24

run: examples/blog/build
cp node_modules/fakerest/dist/FakeRest.min.js examples/blog/build/fakerest.js
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"node": ">=4.2.0"
},
"scripts": {
"test": "make test"
"test": "make test",
"postinstall": "./node_modules/protractor/bin/webdriver-manager update --versions.chrome=2.24"
}
}

6 comments on commit 9a845e4

@Phocea
Copy link
Contributor

@Phocea Phocea commented on 9a845e4 Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpetitcolas, @Kmaschta I have a npm issue with that change :(
If I change my package.json to include this commit then this is the error I receive (I have masked some of the path for clarity):

[INFO] > ng-admin@1.0.0-beta3 postinstall D:\......\webpack\node_modules\ng-admin
[INFO] > ./node_modules/protractor/bin/webdriver-manager update  --versions.chrome=2.24
[INFO] 
[ERROR] '.' is not recognized as an internal or external command,
[ERROR] operable program or batch file.
[ERROR] npm WARN EPEERINVALID grunt-karma@0.7.3 requires a peer of karma@~0.12.0 but none was installed.
[ERROR] npm WARN EPEERINVALID karma-mocha@0.1.10 requires a peer of mocha@* but none was installed.
[ERROR] npm WARN EPEERINVALID url-loader@0.5.7 requires a peer of file-loader@* but none was installed.
[ERROR] npm ERR! Windows_NT 6.1.7601
[ERROR] npm ERR! argv "D:\\......\\webpack\\node\\node.exe" "D:\\.....\\webpack\\node\\node_modules\\npm\\bin\\npm-cli.js" "install" "--strict-ssl=false" "--color=false"
[ERROR] npm ERR! node v5.1.0
[ERROR] npm ERR! npm  v3.4.0
[ERROR] npm ERR! code ELIFECYCLE
[ERROR] 
[ERROR] npm ERR! ng-admin@1.0.0-beta3 postinstall: `./node_modules/protractor/bin/webdriver-manager update  --versions.chrome=2.24`
[ERROR] npm ERR! Exit status 1
[ERROR] npm ERR! 
[ERROR] npm ERR! Failed at the ng-admin@1.0.0-beta3 postinstall script './node_modules/protractor/bin/webdriver-manager update  --versions.chrome=2.24'.
[ERROR] npm ERR! Make sure you have the latest version of node.js and npm installed.
[ERROR] npm ERR! If you do, this is most likely a problem with the ng-admin package,
[ERROR] npm ERR! not with npm itself.
[ERROR] npm ERR! Tell the author that this fails on your system:
[ERROR] npm ERR!     ./node_modules/protractor/bin/webdriver-manager update  --versions.chrome=2.24

@fzaninotto
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a windows only problem... Sorry, can't help.

@Phocea
Copy link
Contributor

@Phocea Phocea commented on 9a845e4 Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I looked into a simple solution by changing the postinstall to call a local js script rather than the direct command line. The script is then setting the exec differently depending on the OS ..but...
In any case it will fail because it is looking for protractor inside the ng-admin/node_modules folder !

The good news, is that doing it inside a script means that the npm install is successful and I can use the sources

I am adding here the script. Can you test it on your side, and also let me know what is going on with the missing protractor dependency? Is it expected?

/*
 * _postinstall.js is a script that runs automatically after the `npm install`
 */
// Get platform from node
var os = require('os');
var platform = os.platform();

if (platform === 'darwin' || platform == 'linux') {
  // Call child process and execute
  var exec = require('child_process').exec;

  exec('./node_modules/protractor/bin/webdriver-manager update --versions.chrome=2.24', function (error, stdout, stderr) {
    console.log('Setting up Selenium Server');
    console.log(stdout);

    if (error !== null) {
      console.log(error);
    } else {
      console.log('Selenium Server setup was successful.');
    }
  });

  return;
} else if (platform === 'win32') {
  var exec = require('child_process').exec;

  exec('node.exe node_modules/protractor/bin/webdriver-manager update --versions.chrome=2.24', function (error, stdout, stderr) {
    console.log('Setting up Selenium Server');
    console.log(stdout);

    if (error !== null) {
      console.log(error);
    } else {
      console.log('Selenium Server setup was successful.');
    }
  });

  return;
}

console.error('Unknown environment. Please log an issue at https://github.com/marmelab/ng-admin/issues:', platform);
process.exit(1);

and in package.json simply:
"postinstall": "node.exe _postinstall.js"

@Kmaschta
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node.exe won't pass on unix. Is there a node shortcut to run node.exe on windows?

@Phocea
Copy link
Contributor

@Phocea Phocea commented on 9a845e4 Dec 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kmaschta you are right, then just use:

"postinstall": "node _postinstall.js"

This is accepted under Windows and Linux :)

@Kmaschta
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Can you make a PR for that?

Please sign in to comment.