Skip to content

Commit

Permalink
mise en place de la couverture de code...
Browse files Browse the repository at this point in the history
  • Loading branch information
lowzonenose committed Jun 21, 2018
1 parent 094bf12 commit 41e9e5b
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 3 deletions.
63 changes: 60 additions & 3 deletions COMPILE.md
Expand Up @@ -73,8 +73,9 @@ Liste des targets disponibles :
build[:dev|:prod|:ol[:dev|:prod]|:leaflet[:dev|:prod]|:itowns[:dev|:prod]|:mix[:dev|:prod]],
sample, (doc)
sample:serve, doc:serve
option : --env.production, --env.development, (--env.clean)
--env.leaflet, --env.openlayers, --env.itowns, --env.mix
option : --env.production,
--env.development,
(--env.clean)

### Installation des dépendances

Expand Down Expand Up @@ -184,7 +185,63 @@ Mais il est aussi possible de les executer autrement :
Le navigateur s'ouvre sur la page des exemples sur l'URL suivante :
http://localhost:9001/

### Les tests de rendu
### Les tests

#### Unitaires

**ouvrir une console :**

npm run test

#### Fonctionnels

**ouvrir une console :**

npm run test:serve

Le navigateur s'ouvre sur la page des tests sur l'URL suivante :
http://localhost:9001/

**Note**
> les tests unitaires sont disponibles aussi sur la page de Tests
#### Couverture du code

**ouvrir une console :**

npm run cover

**Résultats :**

-----------------------------|----------|----------|----------|----------|
File | % Stmts | % Branch | % Funcs | % Lines |
-----------------------------|----------|----------|----------|----------|
All files | 20.57 | 18.38 | 14.96 | 20.57 |
Controls | 16.06 | 8.37 | 11.96 | 16.06 |
AttributionDOM.js | 96.77 | 50 | 85.71 | 96.77 |
DrawingDOM.js | 42.31 | 36.26 | 36.67 | 42.31 |
ElevationPathDOM.js | 80.58 | 29.17 | 55.56 | 80.58 |
GetFeatureInfoDOM.js | 96.55 | 50 | 80 | 96.55 |
IsoDOM.js | 70.08 | 31.58 | 41.51 | 70.08 |
LayerImportDOM.js | 0.34 | 0 | 0 | 0.34 |
LayerSwitcherDOM.js | 0.39 | 0 | 0 | 0.39 |
LocationSelectorDOM.js | 0.83 | 0 | 0 | 0.83 |
MeasureAreaDOM.js | 3.57 | 0 | 0 | 3.57 |
(...)

Possibilité d'ouvrir ensuite les résultats dans un navigateur :

(http|file)://{URL|PATH}/coverage/lcov-report/index.html

Explications :

statements coverage :
http://istqbexamcertification.com/what-is-statement-coverage-advantages-and-disadvantages/
branchs coverage :
http://istqbexamcertification.com/what-is-decision-coverage-its-advantages-and-disadvantages/
(...)

#### Tests de rendu

**ouvrir une console :**

Expand Down
10 changes: 10 additions & 0 deletions package.json
Expand Up @@ -17,6 +17,7 @@
"clean": "echo \"Warning: target not yet implemented!\" && exit 0",
"test": "cd test && mocha-webpack --require setup.js --webpack-config webpack.test.js --glob \"test-*.js\" spec/Common/*/*",
"test:serve": "cd test && webpack-dev-server --hot --config webpack.test.serve.js",
"cover": "nyc --reporter=lcov --reporter=text npm run test",
"sample": "npm run sample:serve",
"sample:serve": "npm run sample:ol:serve",
"sample:itowns:serve": "webpack-dev-server --config webpack.config.itowns --open-page samples/index-itowns-src.html --contentBase . --port 9001 --open",
Expand All @@ -43,6 +44,13 @@
"build:leaflet:prod": "webpack --config webpack.config.leaflet --env.production",
"build:leaflet": "webpack --config webpack.config.leaflet"
},
"nyc": {
"include": [
"src/**/*.js"
],
"instrument": false,
"sourceMap": false
},
"repository": {
"type": "git",
"url": "https://github.com/IGNF/geoportal-extensions.git"
Expand Down Expand Up @@ -94,11 +102,13 @@
"handlebars-layouts": "^3.1.4",
"handlebars-webpack-plugin": "^1.4.1",
"html-webpack-plugin": "^3.1.0",
"istanbul-instrumenter-loader": "^3.0.1",
"jsdoc-webpack-plugin": "0.0.1",
"jsdom": "^9.9.1",
"mocha": "^5.0.5",
"mocha-loader": "^1.1.3",
"mocha-webpack": "^1.1.0",
"nyc": "^12.0.2",
"path": "^0.12.7",
"requirejs": "^2.3.5",
"speed-measure-webpack-plugin": "^1.2.2",
Expand Down
8 changes: 8 additions & 0 deletions test/webpack.test.js
Expand Up @@ -17,6 +17,14 @@ module.exports = {
},
module : {
rules : [
{
test: /\.js$/,
include: path.resolve('..', 'src'), // instrument only testing sources with Istanbul, after ts-loader runs
loader: 'istanbul-instrumenter-loader',
query: {
esModules: true
}
},
{
test : /\.js$/,
exclude : /node_modules/,
Expand Down

0 comments on commit 41e9e5b

Please sign in to comment.