We are using frisby to run our integration tests and while developing them, it would be handy to execute one specific one or a group of tests, without having run all of them and see extra noise. Right now I am commenting out all the ones I don't want to run, which is getting tedious.
Is there a way, from the command line, to run specific frisby tests?
So basically, instead of
npm test
I want to be able to say
npm test --name: posts
Or something like that. I found this post about jasmine-only, but I'm not sure it will satisfy my needs.
Thanks so much!
I'm not sure if you're still looking for answer, but this is pretty simple.
Firstly install latest version of jasmine-node from command line: npm install jasmine-node -g
Then to run particular test use: jasmine-node --coffee putTestNameHere
Install jasmine-node module. Execute one file at a time - you can group your test cases in specific file:
jasmin-node moduleTestCases_spec.js
Also, if you want to specify exact test case name to be executed, you can make use of sequenty module. It is a nodejs module, which you can specify the order(and thus the exact test cases to execute).
To run specific test in Frishby just run:
npm test ./folder/filename.js
So lets assume you have an folder say test under that you have a file called api.spec.js
then you will execute like this:
npm test ./test/api.spec.js
Parallely don't forget to specify these below things into your package.json file
"scripts": {
"test": "mocha" }
Related
Trying to figure out what putting : in an npm script name does. For example:
package.json
"test:ci": "rest of script"
what would :ci do? running npm run test:ci fails
I can't find anything bash syntax really.
I believe it's just a naming convention to group a set of related tasks. For example you might have
"test:ci": ...
"test:units": ....
"test:integration"...
In this case it is grouping a related set of test tasks.
It would be down to the package author to specify. You can split tasks out like described in the answer above and then have a 'global' test command which combines each of them e.g. test:ci && test:unit && test:integration enabling you to run them all at once or when individually when needed.
You can use npm-run-all (link) and use the command npm-run-all test:*, which would then find all scripts starting with the test: group.
I solved this by running - "npm run <scriptName>"
Within my package.json file, I had two "start scripts"
start: nodemon server.js
start:elasticsearch: docker run elasticsearch..
Solved with npm run start:elasticsearch
If using Yarn package manager, you can use a colon in the name to call the script from any workspace.
According to the yarn docs on How to share scripts between workspaces?:
Little-known Yarn feature: any script with a colon in its name (build:foo) can be called from any workspace.
Also, according to yarn docs on CLI > run:
Otherwise, if the specified name contains a colon character and if one of the workspaces in the project contains exactly one script with a matching name, then this script will get executed.
I have some mocha tests that I run from a docker container which tests some services in other running docker containers.
Right now, I have a shell script that finds all the mocha js files, de-newlines them and passes them as an argument to mocha itself. That script then gets run in a docker container as the dockerfile CMD.
This works ok, but it is kind of hacky and is starting to get ugly with several dozen js files.
In javaland, I'd let maven run these, but I figure there must be something better suited for node/javascript.
You can either use mocha --recursive path/to/tests if you want recursively go through all folders and run all files as tests, or you can use globs to pass to mocha like mocha tests/**/test-*.js to filter out specific files matching a pattern.
I'm trying to create a custom build with core-js. Per the documentation, I first ran
npm i core-js && cd node_modules/core-js && npm i
which seemed to be fine. Then, also per the docs I tried
C:\GIT\coreJS_Custom\node_modules\core-js>npm run grunt build:es6.array.from -- --library=on --path=custom uglify
and lots of variations on that theme. It seems to run briefly, with no output at all, and I can't seem to find any generated file. What am I doing wrong?
Also, the above commands were run on the Windows 8.1 cmd terminal.
What's particularly interesting (and frustrating) is that running this
C:\GIT\coreJS_Custom\node_modules\core-js>npm run grunt kjhgjhghkghh
Similarly runs briefly and then seems to succeed.
I'm not sure what my root problem is, but for me, running the grant task on its own, without npm run did the trick
So something like this should be the final product.
C:\GIT\coreJS_Custom\node_modules\core-js>grunt build:es6.array.from --library=on --path="es6-array-from-build-min2" uglify
I am working on an angular js project and I would like to automate The following two commands.
./node_modules/protractor/bin/webdriver-manager update
./node_modules/protractor/bin/webdriver-manager start
The issue is that I am working on a small angular project on github. I added all dependencies required to my package.json, However when my friend pulled it from git he was able to install protractor but he could not get webdriver to start unless he ran the above two commands. So i wanted to write some script to automate it and better yet even add protractor ./conf.js to it.
So I did research and I am aware that I can write a npm script but I was not able to find a proper document that showed where to write the script and how to execute it. I would appreciate all suggestions.
You can add a scripts property to your package.json with the command you wish you run.
"scripts": {
"prostart": "./node_modules/protractor/bin/webdriver-manager start",
"proupdate": "./node_modules/protractor/bin/webdriver-manager update"
}
you would then run these by typing npm run prostart or npm run proupdate which would look for those commands in your package.json.
In addition to Josh's answer, the script start could be run as npm start as start is a special keyword, but update should be run as npm run update because npm update is another npm command entirely.
For any other command besides start and test (I think), you have to preface it with npm run ...
I am sure I am missing something obvious here!
I have read the instructions here (https://github.com/visionmedia/mocha/wiki/Third-party-reporters), and have taken their code and added as a new node module (i.e. it is within node_modules/my-reporter/reporter.js). However, I can't seem to get mocha to load this reporter.
I have tried numerous variations …
mocha allTests.js -R ./node_modules/my-reporter/reporter.js
mocha allTests.js -R my-reporter
But nothing works :-(
I can successfully load my reporter within a JS file:
my_reporter = require('./node_modules/my-reporter/reporter.js')
console.log(my_reporter);
Has anyone got any hints?
u should provide the reporter like this:
mocha allTests.js -R './node_modules/my-reporter/reporter'
You should not provide the .js file extension as that is the normal convention for including modules.
It appears that if mocha is installed globally (which I believe it almost always is), you have to install your reporter the same way.
If you don't want to publish the reporter as a public module, you can just:
npm pack
npm install /path/to/your/module.gz -g
I've tried putting the reporter everywhere else that would make sense, but was getting "invalid reporter" unless it was installed globally.