Temporary files on Travis - node.js

I have a Javascript project which uses Grunt for build process, QUnit for tests, Blanket for code coverage and a custom Grunt task to convert coverage results into LCOV files, sended to Coveralls. Everything running on TravisCI.
the project : https://github.com/mistic100/jQuery-QueryBuilder
my Grunt task : https://github.com/mistic100/grunt-qunit-blanket-lcov
So what should happen is that npm test runs QUnit+Blanket tests in a PhantomJS process and in the meanwhile, coverage results are saved in .coverage-results/all.lcov.
After a successfull build, grunt coveralls sends this file to Coveralls.
And my problem is here, the task does not find the file, although when I test on my computer it does.
see the last Travis log: https://travis-ci.org/mistic100/jQuery-QueryBuilder#L389
The only thing I can think about is that the file, for some reason, is deleted once npm test is finished. Is it possible ?
edit
so this has nothing to do with Travis but with my Grunt task where I use absolute paths thinking it's relative paths (I still don't know why it doesn't append on Windows though)

The only thing I can think about is that the file, for some reason, is deleted once npm test is finished. Is it possible ?
No, lifecycle-wise the build artefacts are still present, when running after_success commands.
The gruntfile.js configures force true and defines path - no issue here.
This should work.
I would suggest to throw in some commands to check the folders and files on Travis.
- sudo ls -alh /home/travis/build/mistic100/jQuery-QueryBuilder/*
- sudo ls -alh /home/travis/build/mistic100/jQuery-QueryBuilder/.coverage-results/*
Maybe you spot a permission issue during folder and file creation.
But that's my only guess.

Related

How to prevent testing-libarary running coverage on untested files every time I save my test file?

I am using the test-library for React , and everytime I edit my test file and save it, it will automatically running coverage on other untested files and gave me a report. there are hundreds of files in my project,and it could really waste time. I don't want this, I just want it run test on my current selected file.
the command I have used is
npm run test /myprojrct/myFile.test.js
is there a way to resolve it ?
Adding the --watch flag to your test script should make jest run tests only on changed files after each save.
More details and other available options can be found here: https://jestjs.io/docs/en/cli#--watch
You should add --coverage=false flag to prevent collecting coverage.
npm run test --coverage=false
Other useful flags:
npm run test --watch // watcher will re-run only the tests that depend on the changed files
npm run test --watchAll // watcher will re-run *ALL* tests when a file has changed
npm run test -t="rendering Button" // will run only tests with a name that matches the regex
npm run test fileName.js // this argument will be treated as a regular expression to match against files in your project

Cannot build / run test properly in travis. Permission denied

I have a simple node.js code/project. I write some test with jestjs. I run the test on my local machine with the command 'npm run test'. The test is able to pass.
I moved the project onto GitHub and wanted to tinker with Travis CI. But my build on travis ci fails. The error message on travis is shown below.
Below is the state of my Git repo:
I never committed the folder 'node_modules' into Git because I read somewhere that this folder should be excluded as Travis would have its 'own environment to run and build the project'.
Below is my .travis.yml :
Below is my package.json file:
I tried modifying this file as well. I am still stuck, Should I remove the lines that states the "build" ?
Appreciate any help!
Maybe try adding the following to travis.yml
before_script: chmod 0555 ./node_modules/.bin/travis
I resolved the situation by adding the below:
before_script: chmod 0555 ./node_modules/.bin/jest
I think this is trying to tell the machine running to allow the use of the jest library. Therefore the jests unit test is able to run properly.

Plesk Git additional deploy actions npm not executed

I've connected Plesk to GitHub. Plesk gives the opportunity to run additional deployment actions after a branch was pulled. Pulling the branch works fine.
But it seems, that these actions are not triggered.
I want to run the install:prod task from my package.json file.
I can run this successfully via ssh.
I've also tried to skip the prepending "npm run" part but without success.
My current configuration looks like this.
npm run install:prod
The logs are showing no error message. It seems to silently fail.
I had the same problem. The solution for me was to use the correct path on the additional deploy scripts, you can find out those by doing "which npm" and "pwd" for getting your website dir path. Once you have those you could use this lines on your deploy scripts, for example, assuming "httpdocs" is where your website is:
cd /var/www/vhosts/<your vhost>/httpdocs
/usr/bin/npm run install:prod

How to run npm tests from a single folder?

Currently I am testing a React node application, and have all my tests in the root/tests folder, with components in separate folders pertaining to their function.
I have 10+ folders and 100+ tests, and would like to 'watch' a single folder while I write a test for a new component.
Currently, I am using
npm run test:watch
Which is working brilliantly, however, not only is there a lot of overhead re-running the 100 other tests not related to my new component, it's also hard to weed through all the feedback to see the results of my current test.
Is there a nice command to only watch the directory of my new test, or even the test file?
You can pass mocha test directory to the npm command:
npm run test:watch -- root/tests/subfolder
However it might depend on how your test script test:watch is defined.

Use jasmine-node to test meteor application with auto-test

I'm using jasmine-node to test my Meteor application and I want to use the auto-test feature so I don't have to rerun the tests all the time by myself.
My meteor application folder structure is like this:
server
foo.coffee
tests
foo.spec.coffee
And with the spec file I want to test code which is located in foo.coffee. I start jasmine-node with this args:
jasmine-node ./ --autotest --coffee --test-dir tests
And now I would assume that the autotest feature will react on all changes in the root folder but it just reacts on changes in the test folder. And I can't start it in the root folder because I get an error in the .meteor files (and I don't want to have jasmine testing/including the meteor code anyway).
So I want to have jasmine rerun the tests even if I change code in the server folder. How can I achieve that?
Use the --watch parameter along with --autotest and specify the directories that contain whatever files you want to have watched.

Resources