nodejs, run test automatically when files change - testing

Is there a way to automatically run tests, when a file in the app is changed? In rails there is a gem called guard. How can one achieve the same in nodejs?

Not sure if this would work for tests, but Nodemon (https://github.com/remy/nodemon) looks like what you want.

Install Jasmine and run
jasmine-node <dir> --autotest

Try this
touch /tmp/nt; while [ true ]; do if [ find . -newer /tmp/nt -type f
| grep -v app/cache | wc -l -gt 0 ]; then phpunit; touch /tmp/nt; fi;
sleep 5; done
I'm using it to autostart phpunit. Replace phpunit with the command to run tests
replace sleep 5 with sleep 1 if you wish to check every second (depends on the size of your files)

Related

Starting Synergy during gdm startup (greeter) in CentOS8

This is similar to Starting synergy automatically on RHEL/CentOS
However this doesn't seem to be working anymore.
What I basically want to do is execute a program when the greeter is shown. THis has been working before by adding it to the /etc/gdm/Init/Default script.
However right now the script doesn't seem to be called anymore (tested with a 'logger' call).
SElinux is in permissive mode. The script is executable. synergyc is specified with the full path.
The below resolves the issue. So to make synergyc always running at the GDM greeter use the PostSession script below and put the /usr/share/gdm/greeter/autostart/synergyc.desktop file into place:
[Desktop Entry]
Type=Application
Name=Synergy Client
Exec=synergyc 192.168.1.110
X-GNOME-AutoRestart=true
/etc/gdm/PostSession/Default:
#!/bin/sh
# Kill old process
/usr/bin/killall synergyc
while [ $(pgrep -x synergyc) ]; do sleep 0.1; done
# Get the xauthority file GDM uses, setup DISPLAY var and start synergyc again
xauthfile=$(ps aux |grep Xauth | grep '^gdm' | grep -oP '\-auth \K[\w/]+')
export DISPLAY=:0
export XAUTHORITY=${xauthfile}
/usr/bin/synergyc 192.168.1.110
exit 0

Gitlab-ci runner hangs after cypress tests

I am using gitlab-ci to tests a react application with cypress.
The test seems to pass but it hangs after executing cypress run command.
Thus, the test fails because of the timeout.
My service is the following
cypress:
image: cypress/base:10
script:
- serve -s build -l 3000 & yarn wait-on http://localhost:3000
- yarn cypress:run
And in my package.json
{
...
"scripts": {
"cypress:run": "cypress run --spec 'cypress/integration/**/*spec.js' --record false --config video=false"
},
...
}
This is the end of gitlab-ci runner's log:
✔ All specs passed! 01:01 11 11 - - -
Done in 73.82s.
ERROR: Job failed: execution took longer than 20m0s seconds
this issue occurs when a background task is running in the runner
To fix this I put in an or condition on the cypress:run step and kill the process if the result is not a success
there is another kill statement added in the step below also in case -parallel is used and multiple steps are running
Something like this
script:
# start the server in the background
- npx serve -s build -p 3001 &
# run Cypress tests in parallel
- yarn cypress:run || (ps -ef | grep [s]erve| awk '{print $2}' | xargs kill -9 )
- (ps -ef | grep [s]erve| awk '{print $2}' | xargs kill -9 ) || exit 0
I don't know if this can help someone, but it is worth to try updating node.
I had the same problem when using cypress 11.1.0 and node:16.17.1-slim docker image. I do not experience hang ups with node:16.18.1-slim anymore.
P.S. Along with node update I've updated Chrome from 106 to 107, so can't be sure what actually made the trick, just wanted to share with possible solution.

Bash script in Mac OS X app, calling custom app from system

In my bash script i have:
program=*program_name*
condition=$(which $program 2>/dev/null | grep -v "not found" | wc -l)
if [ $condition -eq 0 ] ; then
echo "$program is not installed";
echo -n *mypass* |sudo -S gem install $program;
fi
First of all, it installs program every time. It shows that program is not installed, but i can use it from terminal.
...then, i need to use this program in my cocoa application, for example
program --help
Using
system([pathToFile UTF8String]);
i get:
path_to_bundle/myBashScript.sh: Permission denied // Where path is in bundle
path_to_folder/myBashScript.sh:line 30: program: command not found // Where path is from other system folder
Using NSTask i get program: command not found every time.
I don't understand why this is happening. And i would like to know how i can use this program in my cocoa app.
So, i have found the solution.
When you're trying to run the custom system program from the cocoa app, you should give the full path to the binary.
The problem is in:
program=*program_name*
*program_name* should be full path to binary, in my case it was /Library/Ruby/Gems/2.0.0/gems/program-version/bin/program
For additional information about installation paths:
https://wiki.haskell.org/Mac_OS_X_Common_Installation_Paths
http://help.rubygems.org/discussions/problems/739-how-to-run-applications-installed-by-gem

Grunt + Functional Testing

I have grunt tasks setup to do some functional tests with CasperJS on my local machine. Everything is working fine.
I'd like to know if there is a way to keep running the tests until it fails? Or run through the tests a certain number of times?
In powershell you can "cd" to the directory and use the following one-liner:
do { grunt } while (1 -eq 1}
Here is the equivalent in Bash:
while [ 1 -eq 1 ]; do grunt done
This should run grunt over and over in an infinite loop and you can stop with ctrl + c. If you want it to stop as soon as it fails you will need a script (I am providing the Bash as I am not very familiar with powershell):
#! /bin/sh
result=0
while [ $result -eq 0 ]; do
grunt || result=1
done

Guard complaints about running outside of Bundler, but only on 2nd terminal window onwards

I am following Michael Hartl's tutorial and ran this 2 blocks of code
$ rvm get head && rvm reload
$ chmod +x $rvm_path/hooks/after_cd_bundler
$ cd ~/rails_projects/sample_app
$ bundle install --without production --binstubs=./bundler_stubs
now when I run Guard on my first terminal window everything is fine, but when I open another terminal window and run the exact same command, it complaints that I am running Guard outside of Bundler. Why is that so?
Still can't post images but here is the screenshot of the 2 separate terminal windows
terminal 1
terminal 2
Thanks!
Ryan
tests
rvm current - is the proper ruby selected
echo $PATH - first position should be path to .../bundler_stubs
solutions
for both errors it might work again with cd . - but this might be problematic
you need to make sure that RVM was loaded properly, and that proper ruby was loaded in session:
make sure you use gnome-terminal with login session enabled: https://rvm.beginrescueend.com/integration/gnome-terminal/
run rvm get head --auto - keep a gist of it in case
restart your computer - it's required in some cases
make sure you do not overwrite PATH after RVM was loaded in your RC scripts