Package.json points to the main script files and dependencies necessary to do all your testing. Fonteva makes package.json available for download at their Github repositories.

Unless absolutely necessary, do not edit package.json.


package.json

{
  "name": "auraspecs",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "test": "mocha  --require babel-register --require mocha-aura --reporter progress \"specs/**/*.js\"",
    "test-jenkins": "JUNIT_REPORT_STACK=1 mocha --require babel-register --require mocha-aura --no-colors --reporter mocha-multi --reporter-options mochawesome=/dev/null,mocha-jenkins-reporter=- 'specs/**/*.js'",
    "watch": "chokidar --initial './specs/**' '../src/aura/**/*.js' -c 'npm run test'",
    "watch-coverage": "chokidar --initial './specs/**' '../src/aura/**/*.js' -c 'npm run coverage'",
    "precoverage": "babel -q ./specs -d ./distspecs",
    "coverage": "istanbul cover -x \"distspecs/**/*.js\" --root \"../src/aura\" --include-all-sources --post-require-hook mocha-aura ./node_modules/mocha-runner/bin/runner.js -- --reporter min --quiet \"distspecs/**/*.js\" html text-summary",
    "postcoverage": "rm -rf ./distspecs",
    "coverage-jenkins": "npm run coverage && istanbul report cobertura",
    "nuke": "rm -rf ./node_modules && rm -f yarn.lock && yarn cache clean && yarn install"
  },
  "auraPath": "../src",
  "devDependencies": {
    "babel-cli": "^6.24.1",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-register": "^6.24.1",
    "chokidar-cli": "^1.2.0",
    "istanbul": "^0.4.5"
  },
  "dependencies": {
    "babel-preset-env": "^1.6.1",
    "chai": "^3.5.0",
    "lodash": "^4.17.5",
    "mocha": "^3.5.3",
    "mocha-aura": "git+ssh://git@github.com/Fonteva/mocha-aura.git#0.2.1",
    "mocha-fonteva-adapters": "git+ssh://git@github.com/Fonteva/mocha-fonteva-adapters.git#0.2.1",
    "mocha-fonteva-data-generator": "git+ssh://git@github.com/Fonteva/mocha-fonteva-data-generator.git#0.1.2",
    "mocha-jenkins-reporter": "^0.3.10",
    "mocha-multi": "^0.11.1",
    "mocha-runner": "^1.1.2",
    "mochawesome": "^2.3.1",
    "npm": "^6.0.0",
    "sinon": "^2.4.1",
    "sinon-chai": "^2.14.0"
  }
}
JS

Fonteva provides some standard code:

  • Dependencies are indicated in devDependencies (line 18)Istanbul and others.
    Aura is located at "auraPath": "../src"   (line 17).
  • Other dependencies are located in dependencies (line 25).

There are some dependencies that aren't on the npm registry (e.g., mocha-aura,  mocha-fonteva-adapters, mocha-fonteva-data-generator). These connect directly to our repositories (https://github.com/Fonteva). You can download the latest versions from there. The scripts are everything you need to run the testing environment.

The following examples (in yellow) illustrate the three scripts you need to be concerned about:

  • nuke - This deletes all node modules and then re-installs them from scratch. This can be run each time you are testing in an automated fashion. It takes about 20 seconds, and you can be sure you’re testing in a clean state.
  • test - This command runs the tests you write.
  • coverage - This command generates coverage reports that show you which lines of code run and how often they run.

 

nuke

To run nuke in the auraSpecs directory, use the following command:

 npm run nuke
CODE

This command runs the following:

package.json

rm -rf ./node_modules && rm -f yarn.lock && yarn cache clean && yarn install
CODE

run is an npm command; nuke is the script you want to run.

 

 

test

To run test, use the following command

 npm run test
CODE

 This runs the following:

package.json

"test": "mocha --require babel-register --require mocha-aura --reporter progress \"specs/**/*.js\""
CODE

The result is a pass/fail report that will show you what failed and why it failed.

 

 

 

coverage

For coverage, run the following command:

nmp run coverage
CODE

 This command runs the following script:

package.json

 "coverage": "istanbul cover -x \"distspecs/**/*.js\" --root \"../src/aura\" --include-all-sources --post-require-hook mocha-aura ./node_modules/mocha-runner/bin/runner.js -- --reporter min --quiet \"distspecs/**/*.js\" html text-summary"
CODE

This generates the coverage reports. When it finishes, a log will be generated in the following file.

/users/<user>/.npm/_logs/<date-time-debug.log>
CODE

GURP WILL GET US BETTER SCREENSHOTS FOR THE BELOW.

An HTML report will be in auraSpecs/coverage/lcov-report/index.html

This displays your coverage data for all of your aura components. Yellow, green, and red show how much coverage you have. Red indicates that particular line did not get executed.

For example, click on the ConferenceEvent component.

Then click on ConferenceEventController.js.

The number of times each line has run displays in the column on the left.

Items displayed in red did not execute. The second column displays the number of times each line executed.

 

Previous: Installation     |     Next: Directory Structure and Files