Let's see a typical example of package.json
, which is using the following:
Mocha as a testing framework
Expect as an assertion library
ReactTestUtils to test react-based JavaScript components
Babel used as a transcompiler, which changes the ES6 codes into currently compatible (ES5) JavaScript code.
The example of package.json
file:
"scripts": { "test": "mocha './src/**/*.test.js' --compilers js:babel-core/register", }, "devDependencies": { "babel-core": "6.1.4", "babel-loader": "6.1.0", "babel-preset-es2015": "6.1.4", "babel-preset-react": "6.1.4", "babel-preset-stage-2": "6.1.2", "mocha": "2.3.3", "react-addons-test-utils": "0.14.3", } }
As in the previous examples, within the script object, we keep the the test files and all the test files follow the convention of ending with the .test.js
extension. Any extension for the test files can be used. For compilation from ES6 code...