1
votes

I have an Ember CLI project which I am building using Maven, and I am trying to figure out how to have maven be able to run the tests without a prior assumption of having PhantomJS globally installed. I am using the frontend-maven-plugin to install specific versions of node and npm on the fly, to call npm install, bower install, and ember build; this all already works. What I am trying to do now is also call ember test, and fail the maven build if the tests fail. Currently, this works as long as "phantomjs" is in the path of the machine running the maven build; however, many developers use this build who are not ember developers and wouldn't have phantomjs in their path. Nor do I want to have to make sure to globally install phantomjs on my CI servers.

Is there some way to specify PhantomJS as a dependency in package.json and have testem (the default test runner for ember) pick up the installation in node_modules? Can I supply the path to PhantomJS to testem in some way that is not obvious from the docs? Or do I just have to live with a hidden manual dependency if I want to run tests?

1

1 Answers

3
votes

Yes, you can do exactly that.

First, install phantomjs-prebuilt as a dev dependency:

npm install --save-dev phantomjs-prebuilt

Then alter your package.json scripts to add the project-local node_modules to your path before running tests:

    "scripts": {
      "build": "ember build",
      "start": "ember server",
      "test": "PATH=$PATH:./node_modules/.bin ember test"
    },

Then run your tests as normal

npm install && bower install && npm test

This will launch your project-local version of phantomjs to run the tests.