# HG changeset patch # User Nicolas Chevobbe # Date 1518448315 -3600 # Node ID 04f9bdfbff97c5daa0a4c9b0d950fb5134213c03 # Parent 1eaafc62489f26432aa321da1640f10a32ad5c41 Bug 1436690 - Add a webconsole tests dedicated package.json file; r=bgrins. This will free the tests of the devtools-launchpad dependency so we have a more robust workflow. Also, this will facilitate running those tests on CI. MozReview-Commit-ID: JkF89YBxlO4 diff --git a/devtools/client/webconsole/.babelrc b/devtools/client/webconsole/.babelrc --- a/devtools/client/webconsole/.babelrc +++ b/devtools/client/webconsole/.babelrc @@ -1,12 +1,14 @@ { "env": { "test": { - "presets": ["es2015", "es2017"] + "plugins": [ + "./new-console-output/test/node_modules/babel-plugin-transform-object-rest-spread" + ] } }, "plugins": [ + "transform-flow-strip-types", "transform-react-jsx", - "transform-object-rest-spread", - "transform-flow-strip-types" + "transform-object-rest-spread" ] } diff --git a/devtools/client/webconsole/new-console-output/test/README.md b/devtools/client/webconsole/new-console-output/test/README.md --- a/devtools/client/webconsole/new-console-output/test/README.md +++ b/devtools/client/webconsole/new-console-output/test/README.md @@ -1,28 +1,34 @@ # Console Tests The console panel uses currently two different frameworks for tests: * Mochitest - [Mochitest](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Mochitest) is an automated testing framework built on top of the MochiKit JavaScript libraries. It's just one of the automated regression testing frameworks used by Mozilla. -Mochitests are located in `new-console-output/test/mochitest/` and can be run with the following command: +Mochitests are located in `devtools/client/webconsole/new-console-output/test/mochitest/` and can be run with the following command: ```sh ./mach test devtools/client/webconsole/new-console-output/test/mochitest/ ``` These tests can be run on CI when pushing to TRY. Not all tests are enabled at the moment since they were copied over from the old frontend (See Bug 1400847). * Mocha + Enzyme - [mocha](https://mochajs.org/) Mocha is JavaScript test framework running on Node.js [Enzyme](http://airbnb.io/enzyme/) is a JavaScript Testing utility for React that makes it easier to assert, manipulate, and traverse your React Components' output. These tests are located in `new-console-output/test/components/` and `new-console-output/test/store/`, and can be run with the following command: ```sh -npm test # Or yarn test +devtools/client/webconsole/new-console-output/test/ && npm install && npm test +``` + +or using yarn with + +```sh +devtools/client/webconsole/new-console-output/test/ && yarn && yarn test ``` **⚠️️️️️️️️️️ These tests are not ran on CI at the moment. You need to run them manually when working on the console. (See Bug 1312823)** --- The team is leaning towards Enzyme since it's well known and suitable for React. It's also easier to contribute to tests written on top of Enzyme. diff --git a/devtools/client/webconsole/package.json b/devtools/client/webconsole/new-console-output/test/package.json copy from devtools/client/webconsole/package.json copy to devtools/client/webconsole/new-console-output/test/package.json --- a/devtools/client/webconsole/package.json +++ b/devtools/client/webconsole/new-console-output/test/package.json @@ -1,44 +1,30 @@ { - "name": "webconsole", + "name": "webconsole-tests", "version": "0.0.1", "engines": { "node": ">=6.9.0" }, "scripts": { - "preinstall": "cd ../netmonitor && npm install && cd ../webconsole", - "start": "cross-env NODE_ENV=production node bin/dev-server", - "dev": "node bin/dev-server", - "test": "cross-env NODE_ENV=test NODE_PATH=../../../ mocha new-console-output/test/**/*.test.js --compilers js:babel-register -r jsdom-global/register -r ./new-console-output/test/require-helper.js" + "test": "cross-env NODE_ENV=test NODE_PATH=../../../../../ mocha \"./**/*.test.js\" -r babel-register -r jsdom-global/register -r ./mocha-test-setup.js" }, "dependencies": { - "amd-loader": "0.0.5", - "babel-plugin-transform-flow-strip-types": "^6.22.0", - "babel-plugin-transform-react-jsx": "^6.24.1", "babel-plugin-transform-object-rest-spread": "^6.26.0", - "babel-preset-es2015": "^6.6.0", - "babel-preset-es2017": "^6.24.1", - "babel-register": "^6.24.0", + "babel-register": "^6.26.0", "cross-env": "^3.1.3", - "devtools-config": "0.0.12", - "devtools-launchpad": "0.0.115", - "devtools-modules": "0.0.31", - "devtools-source-editor": "=0.0.3", - "enzyme": "^2.4.1", + "enzyme": "^3.3.0", + "enzyme-adapter-react-16": "^1.1.1", "expect": "^1.16.0", - "file-loader": "^0.10.1", - "immutable": "^3.8.1", "jsdom": "^9.4.1", "jsdom-global": "^2.0.0", - "json-loader": "^0.5.4", - "mocha": "^2.5.3", - "raw-loader": "^0.5.1", - "react": "=15.3.2", - "react-addons-perf": "=15.3.2", - "react-dom": "=15.3.2", - "react-redux": "=5.0.3", - "redux": "^3.6.0", + "mocha": "^5.0.0", + "netmonitor": "file:../../../netmonitor", "require-hacker": "^2.1.4", - "reselect": "^3.0.1", - "sinon": "^1.17.5" + "sinon": "^1.17.5", + "chai": "^4.1.2", + "es6-promise": "^4.2.4", + "nock": "^9.1.6", + "tap": "^11.1.0", + "react": "^16.2.0", + "react-dom": "^16.2.0" } } diff --git a/devtools/client/webconsole/package.json b/devtools/client/webconsole/package.json --- a/devtools/client/webconsole/package.json +++ b/devtools/client/webconsole/package.json @@ -1,44 +1,29 @@ { "name": "webconsole", "version": "0.0.1", "engines": { "node": ">=6.9.0" }, "scripts": { - "preinstall": "cd ../netmonitor && npm install && cd ../webconsole", "start": "cross-env NODE_ENV=production node bin/dev-server", - "dev": "node bin/dev-server", - "test": "cross-env NODE_ENV=test NODE_PATH=../../../ mocha new-console-output/test/**/*.test.js --compilers js:babel-register -r jsdom-global/register -r ./new-console-output/test/require-helper.js" + "dev": "node bin/dev-server" }, "dependencies": { - "amd-loader": "0.0.5", "babel-plugin-transform-flow-strip-types": "^6.22.0", "babel-plugin-transform-react-jsx": "^6.24.1", "babel-plugin-transform-object-rest-spread": "^6.26.0", - "babel-preset-es2015": "^6.6.0", - "babel-preset-es2017": "^6.24.1", - "babel-register": "^6.24.0", "cross-env": "^3.1.3", "devtools-config": "0.0.12", "devtools-launchpad": "0.0.115", "devtools-modules": "0.0.31", - "devtools-source-editor": "=0.0.3", - "enzyme": "^2.4.1", - "expect": "^1.16.0", - "file-loader": "^0.10.1", - "immutable": "^3.8.1", - "jsdom": "^9.4.1", - "jsdom-global": "^2.0.0", - "json-loader": "^0.5.4", - "mocha": "^2.5.3", + "file-loader": "^1.1.6", + "netmonitor": "file:../netmonitor", "raw-loader": "^0.5.1", "react": "=15.3.2", "react-addons-perf": "=15.3.2", "react-dom": "=15.3.2", "react-redux": "=5.0.3", "redux": "^3.6.0", "require-hacker": "^2.1.4", - "reselect": "^3.0.1", - "sinon": "^1.17.5" } }