Closed gianpierobozza closed 3 years ago
Installation: (from docs page) $ npm install karma-jasmine karma-chrome-launcher --save-dev Installs all the dependencies $ npm install -g karma-cli
We didn't use the save dev, but installed everything globally instead, for the docker image.
Also i see there is some missing dependency (at least nodejs says so) with karma
core.
Ok, testing what we should do here for the docker image.
# Running Docker nodejs as root
docker run --name nodejs -it --user root pdonorio/jsdev bash
root@dd28614d57f6:/devjs# npm install -g karma karma-cli karma-jasmine karma-chrome-launcher jasmine-core
[...] # installs
root@dd28614d57f6:/devjs# exit
# Running as developer to check binaries
docker exec -it --user developer nodejs bash
developer@dd28614d57f6:/devjs$ karma --version
Karma version: 0.13.22
Great so far.
For Jasmine we have to do some refactor, since i found an npm package: https://github.com/jasmine/jasmine-npm
# On the root shell of nodejs
root@dd28614d57f6:/devjs#
npm install -g jasmine
/usr/bin/jasmine -> /usr/lib/node_modules/jasmine/bin/jasmine.js
/usr/lib
`-- jasmine@2.4.1
+-- exit@0.1.2
+-- glob@3.2.11
| +-- inherits@2.0.1
| `-- minimatch@0.3.0
| +-- lru-cache@2.7.3
| `-- sigmund@1.0.1
`-- jasmine-core@2.4.1
# As developer to check binaries
developer@dd28614d57f6:/devjs$ jasmine init
developer@c48ca39e52b9:/devjs$ more spec/support/jasmine.json
{
"spec_dir": "spec",
"spec_files": [
"**/*[sS]pec.js"
],
"helpers": [
"helpers/**/*.js"
],
"stopSpecOnExpectationFailure": false,
"random": false
}
@gianpierobozza probably this is enough.
If you're ok i will go with Docker image modification as described above.
All good, please install it in the docker image :+1:
Pushed modifications for the docker image.
We can check here the automatic build, and see when it's ready: https://hub.docker.com/r/pdonorio/jsdev/builds/
Build is available. We should see how to run the tests inside one of the restangulask blueprint. I must use a service inside the docker-compose to do so.
Ok so installation is fine. We must create a setup to use it.
We need a ./do
command based on docker-container to launch a bash on nodejs to run karma.
Problems i see:
blueprint.js
must be converted into a static file when running tests for karmaOk, karma command is avaialble:
./do graphbased karma
This opens a shell as "developer" inside the nodejs container. @gianpierobozza may use karma init there. The thing to verify as soon as possible, to close this issue, is what to do with blueprint.js
thanks @pdonorio
is it possible that before the shell is opened the ./do command creates the blueprint.js based on
I see just a few parameters in blueprint.js, so maybe the first approach is okay at the moment, but if the number of params increase the second approach might be better
Usually the ./do command makes the python server create the right parameters inside the blueprint.js. So we may probably produce it somehow (i don't know yet how, i must check the jinja2 documentation).
If this approach works we may do something similar with the json file, since python reads easily json. Just try like this right now and see what errors you get.
Please install into the docker image the following packages:
Karma: a JavaScript command line tool that can be used to spawn a web server which loads your application's source code and executes your tests Installation: (from docs page)
$ npm install karma-jasmine karma-chrome-launcher --save-dev
Installs all the dependencies$ npm install -g karma-cli
Command line helper, run Karma simply by karma from anywhere and it will always run the local versionJasmine: behavior driven development framework for JavaScript that has become the most popular choice for testing Angular applications. Installation: (from Github repo)
mkdir my-project/jasmine
mv jasmine/dist/jasmine-standalone-2.0.0.zip my-project/jasmine
cd my-project/jasmine
unzip jasmine-standalone-2.0.0.zip
This should give us a full running environment for testing the Angular JS part of the framework For an official Angular JS guide on testing refer to this page
Gianpiero