I want to run the tests related to this project on github, see folder test on https://github.com/node-opcua/node-opcua . Unfortunately I have no idea which testing framework was used and how to run all the tests?
First, run npm install
This will install the required dependencies.
You can then use
npm test
See here:
https://github.com/node-opcua/node-opcua/blob/master/package.json#L15
That will run the tests using Mocha.
Related
Can anyone help me to understand that behaviour:
when I ran in terminal jest command: all my tests passed
I have also defined package.json script where I do exactly the same command jest and when i run npm run tests jest command is executed and all my tests passed.
BUT:
I run it on dockerimage. I have copy all project files to Docker, install all depend. and run tests.
npm run tests - failed
jest - passed
I am on the build docker image, in terminal run both commands. I see that they are giving different results. I know that it different OS. maybe different libraries, but npm, node and jest versions are identical.
Looks like running npm run tests behave differently. I'm stuck, don't know what to check, and how to debug it. Where the problem might be?
I'm working on an existing project but I am new to Javascript. The project can be found here, it is JsPsych and I've searched the documentation here and cannot find the answer (http://docs.jspsych.org/)
I don't understand how they are doing unit tests. I have found the "testing" folder and you can view it below, here.
JsPsych test folder
Here's an example called "load.test.js"
const root = '../';
require(root + 'jspsych.js');
require(root + 'plugins/jspsych-single-stim.js');
test('jsPsych should be in the window object', function(){
expect(typeof window.jsPsych).not.toBe('undefined');
});
Does anyone recognize this type of unit test? Is this supposed to be paired with some software? Can someone explain how I would actually run this?
The tests are run with Jest. You can see that jest is called as the test command in package.json.
To run the tests, install node and npm on your system. Then run npm install in the repository's main directory. Then you can run npm test.
One of my co-workers added this Ava package to our setup, and it's done something I've never seen a Node package do before: interfere with other packages! Now when I try to run Mocha I get:
$ node_modules/mocha/bin/mocha test/
Test files must be run with the AVA CLI:
$ ava node_modules/mocha/bin/_mocha
I get that Ava would like to run my Mocha tests, but if I wanted that I'd run ava mocha not mocha. And because a co-worker is using it I can't simply uninstall the package.
Is there any way I can run plain Mocha tests on a machine with Ava installed?
One of the files in test/ imports ava and the imported code will recognise that it's not being run with the correct tooling and throw an error.
Might be worth subdividing your test/ directory to keep tests associated with their respective runners.
test/
ava/
SomeAvaTests.js
mocha/
SomeMochaTests.js
This way you can safely run mocha test/mocha/ and vice versa without worrying about treading on each other's toes.
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" }
I am new to nodejs, npm also angularjs.
I have read and tried the angularjs tutorial project hosted on https://github.com/angular/angular-phonecat.git,
which for me is really exciting because it shows how easy to maintain the modules with bower, testing with jasmine and karma and perform e2e with protractor using npm command,
my question is, if I want to create project something like that, what I must do step by step? Is there any tutorial for creating project setup like that with npm and nodejs, not limited with angularjs but maybe just plain html CSS javascript or maybe with jquery.
Thanks
First install node
then install yeoman with npm install -g yo
then install the desired yeoman generators
for basic web app npm install -g generator-webapp
for angular npm install -g generator-angular
then run the installer generator.
exemple with webapp : yo webapp
or with angular : yo angular
I suggest you to read the yeoman getting started page