I am trying to execute tests via a Heroku pipeline with the following app.json:
{
"environments": {
"test": {
"addons": [
{
"plan": "mongolab:sandbox"
}
],
"scripts": {
"test": "yarn test && ((nohup yarn test:start:api &) && sleep 10 && yarn test:integration)"
}
}
}
}
Locally on my Linux machine the command works but on Heroku I can not reach the API service:
-----> Running test command `yarn test && ((nohup yarn test:start:api &) && sleep 10 && yarn test:integration)`...
yarn run v1.6.0
warning package.json: No license field
$ mocha-webpack --webpack-config ./webpack.config.js --require test/setup.js model/**/*.spec.js api/**/*.spec.js
WEBPACK Compiling...
WEBPACK Compiled successfully in 792ms
MOCHA Testing...
0 passing (1ms)
MOCHA Tests completed successfully
Done in 4.12s.
yarn run v1.6.0
warning package.json: No license field
$ babel-node ./server.js --presets es2015,stage-2
yarn run v1.6.0
warning package.json: No license field
$ mocha-webpack --webpack-config ./webpack.config.js --require test/setup.js model/**/*.integration.js api/**/*.integration.js
WEBPACK Compiling...
WEBPACK Compiled successfully in 1092ms
MOCHA Testing...
User
Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
(node:570) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
Successfully initialized mongoose-seed
Users collection cleared
Successfully created document [0] of User model
Error: Error: connect ECONNREFUSED 127.0.0.1:8080
...
How can I determine the URI to connect to the API-service itself (nohup yarn test:start:api &)?
The API is built with express-restify-mongoose and as it seems there is no out of the box testing like inject with hapijs (https://hapijs.com/api#-await-serverinjectoptions)
How can I make my tests run on Heroku?
Your tests are trying to connect to 127.0.0.1:8080, but your web application is almost certainly running elsewhere. Heroku provides the PORT environment variable telling your back-end code what port it should use.
Try updating your tests to connect to whatever that variable holds instead of 8080.
Related
I'm trying to run a server to see my project on browser, the only way i can do it is running npx mix watch --hot, so after that my project start running at localhost:8080.
But the above command enable hot reload, i would like to know if there is some specific command to just run the server, without enabling hot reloading.
I tried npm mix watch but it not starts the server, just watch the files.
Tried calling manually webpack server with:
./node_modules/.bin/webpack serve --config="./node_modules/laravel-mix/setup/webpack.config.js"
This works (the server starts at localhost:8080 as well) but somehow it activates hot reloading too, idk why.
So, there is some way to just start the server? Without enabling hot reloading?
Here is my webpack.mix.js file:
let mix = require('laravel-mix');
mix.sass('src/scss/app.scss', 'dist/css/')
.js('src/js/app.js', 'dist/js/').react()
.setPublicPath('public');
My package.json has just the default script:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
If you're using Composer you can run php artisan serve, this will start a local php server and serve your web pages to the browser Laravel installation.
I'm using Jenkins pipeline to compile npm app.
I want to use a parameter for my npm app, see each branch will publish the app under different name.
Also, I need some "default value, for the developers when they are working in their local env
for example, my package.json:
{
"name": ${some_env_var} : default_value",
"version: 1.0.0
...
}
does it possible?
I initialized a vue project by vue/cli, and i do not change any code.After init completion, i run the command to start a development server by npm run dev.And the output show the the server running on localhost:8080, but i can not access it neither by localhost:8080 nor 127.0.0.1:8080.
I haved tried to uninstall safety software, choose vue/cli#2, check hosts file.
C:\Users\Administrator\Desktop\cl>node -v
v10.16.3
C:\Users\Administrator\Desktop\cl>npm -v
6.9.0
"webpack-dev-server": {
"version": "2.11.5",
Try npm run serve. You are not telling vue-cli-service to start a server, only to build locally.
I'm trying to build a micro-services applications with JHipster. I'm following this tutorial.
I've successfully run jhipster-registry locally (I've cloned it, then run the commands ./mvnw and yarn start to be able to see the applications registered). Without this yarn start I can't see anything on my browser.
But I want to run my gateway application with the browser sync and I can't because it's focused on jhipster-registry.
I've a backend micro-service on port 8081.
My gateway is configured on port 8080, ./mvnw run successfully and I can see my application on localhost:8080. But I would like to have the hot reload when I run my npm start command on my gateway. I've configured my package.json to run on the port 9061 :
"webpack:dev": "npm run webpack-dev-server -- --config webpack/webpack.dev.js --inline --hot --port=9061 --watch-content-base --env.stats=minimal",
"webpack:dev-verbose": "npm run webpack-dev-server -- --config webpack/webpack.dev.js --inline --hot --port=9061 --watch-content-base --profile --progress --env.stats=normal",
When I run npm start it says I can see my app on localhost:9001, but I'm on the jhipster-registry...
Does someone can help me ?
Thanks to Gael Marziou, I've build the package like if I was in production with the commands :
./mvnw -Pprod package
And then :
java -jar target/jhipster-registry*.war
I've had to up the memory allocated for the build in the package.json file :
"webpack-dev-server": "node --max_old_space_size=6144 node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"webpack": "node --max_old_space_size=6144 node_modules/webpack/bin/webpack.js",
because I had this error :
With Cypress I can test my dev subdomain easily. I have an angular/react application where when I make a dist (including index.html), I want to run Cypress tests against the built files.
Unfortunately, I have no idea how to serve a dist folder, (like serve package of npm) before starting Cypress tests.
I know that I can serve the index.html on another terminal tab, but this is not going to happen on CircleCi (my CI).
Is there anyway that Cypress can replace the localhost and serve static files before starting the actual tests?
I used browser-sync to launch a server that distribute my static files.
You need to install 3 packages: cypress (obviously), browser-sync to launch a server, and npm-run-all to launch a server and cypress consecutively.
npm install --save-dev cypress
npm install --save-dev browser-sync
npm install --save-dev npm-run-all
Here is an example of the npm scripts configuration that you will need to add in your package.json. Don't forget to customize the <port> (ex: 4000) and <folder> that contains the path to your SPA (ex: public).
{
"scripts": {
"cypress": "cypress run",
"server": "browser-sync start --port <port> --server <folder> --no-open",
"test": "run-p -r server cypress"
}
}
Now you have to write your first Hello world test:
describe('My App', function() {
it('is up', function() {
cy.visit('http://localhost:4000');
cy.contains('Hello world!');
});
});
That's it! We can launch our test:
npm test
I did the following:
I installed
npm i serve
and added
serve: "serve -s <build-folder>"
to my package.json. And then in your e.g. travis.yml you add
- npm run serve &
- npm test
The & at the end of your command will make it run in the backend and thus the test can run right after it. Since serve is pretty fast serving the static files there is no need for the npm test to wait either AND you do not have to worry about stopping the npm run serve afterwards since most CI environments are cleaning up background processes automatically after your tests finished.
Most of the information above can also be found here.