gecko-dev/devtools/client/webconsole/test
Alexandre Poirot e3b1b7660f Bug 1517210 - Stop always loading DevTools modules in fresh compartments. r=jandem,nchevobbe
Now, DevTools server is loaded with a custom loader every time we want to debug chrome
resources. We ensure toggling the "invisibleToDebugger" flag on Loader.jsm which itself
propagates to DevTools Sandboxes.

We added calls to force GC in console test to prevent crashes on Windows 7.

Differential Revision: https://phabricator.services.mozilla.com/D20347

--HG--
extra : moz-landing-system : lando
2019-02-19 16:09:48 +00:00
..
chrome Bug 1527826 - Reflect our github org name change in the m-c code; r=nchevobbe 2019-02-15 09:38:53 +00:00
components Bug 1526247 - Rename webconsole-output-wrapper; r=bgrins. 2019-02-11 06:42:28 +00:00
fixtures Bug 1527834 - Rename WebConsoleWrapper:hud to WebConsoleWrapper:webConsoleUI; r=bgrins. 2019-02-15 08:17:43 +00:00
middleware Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00
mochitest Bug 1517210 - Stop always loading DevTools modules in fresh compartments. r=jandem,nchevobbe 2019-02-19 16:09:48 +00:00
store Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00
unit Bug 1514594: Part 3 - Change ChromeUtils.import API. 2019-01-17 10:18:31 -08:00
utils Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00
.eslintrc.mocha.js Bug 1451821 - Move new-console-output content one folder up; r=jdescottes. 2018-04-06 15:03:20 +02:00
README.md Bug 1451821 - Move new-console-output content one folder up; r=jdescottes. 2018-04-06 15:03:20 +02:00
helpers.js Bug 1465635 - Remove Target.activeTab property. r=yulia 2019-02-02 11:24:24 +00:00
mocha-test-setup.js Bug 1512289 - Remove webconsole reverse search pref; r=bgrins. 2018-12-11 13:01:30 +00:00
moz.build Bug 1451821 - Move new-console-output content one folder up; r=jdescottes. 2018-04-06 15:03:20 +02:00
package.json Bug 1462055 - Fixup mocha test paths for webconsole;r=nchevobbe 2018-05-18 11:33:18 -07:00

README.md

Console Tests

The console panel uses currently two different frameworks for tests:

  • Mochitest - 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 devtools/client/webconsole/test/mochitest/ and can be run with the following command:

./mach test devtools/client/webconsole/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 Mocha is JavaScript test framework running on Node.js 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 test/components/ and test/store/, and can be run with the following command:

devtools/client/webconsole/test/ && npm install && npm test

or using yarn with

devtools/client/webconsole/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.

Stubs

Many tests depends on fix data structures (aka stubs) that mimic RDP packets that represents Console logs. Stubs are stored in test/fixtures directory and you might automatically generate them.

Append new Console API stubs

See how to generate stubs for Console API calls.

  • Append new entry into consoleApiCommands array. The array is defined in this module: \test\fixtures\stub-generators\stub-snippets.js
  • Generate stubs with existing mochitest: \test\fixtures\stub-generators\browser_webconsole_check_stubs_console_api.js

Run the generator using mach command. ./mach test devtools/client/webconsole/test/fixtures/stub-generators/browser_webconsole_check_stubs_console_api.js --headless

This will override test/fixtures/stubs/consoleApi.js.

Append new CSS Messages stubs

See how to generate stubs for CSS messages.

  • Append new entry into cssMessage map into stub-snippets.js
  • Generate stubs with: browser_webconsole_check_stubs_css_message.js

This will override test/fixtures/stubs/cssMessage.js.

Append new Evaluation Result stubs

See how to generate stubs for evaluation results.

  • Append new entry into evaluationResultCommands map into stub-snippets.js
  • Generate stubs with: browser_webconsole_check_stubs_evaluation_result.js

This will override test/fixtures/stubs/evaluationResult.js.

Append new Network Events stubs

See how to generate stubs for network events

  • Append new entry into networkEvent map into stub-snippets.js
  • Generate stubs with: browser_webconsole_update_stubs_network_event.js

This will override test/fixtures/stubs/networkEvent.js.

Append new Page Error stubs

See how to generate stubs for page errors.

  • Append new entry into pageError array into stub-snippets.js
  • Generate stubs with: browser_webconsole_update_stubs_page_error.js

This will override test/fixtures/stubs/pageError.js.