bug 1606834: remote: document fdescribe(), fit(), and Mocha flags r=remote-protocol-reviewers,whimboo

We were lacking documentation on how to run inidividual Puppeteer
tests.  It turns out this is not possible yet to do on a per-file
basis, like other test harnesses.

Instead, suggest use of fdescribe()/fit() and recommend some useful
Mocha flags.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Tolfsen 2020-01-03 16:11:19 +00:00
parent 907178db48
commit 1b5c764457

View File

@ -108,7 +108,7 @@ Puppeteer tests
---------------
In addition to our own Firefox-specific tests, we run the upstream
[Puppeteer test suite] against our implementation to track progress
[Puppeteer test suite] against our implementation to [track progress]
towards achieving full [Puppeteer support] in Firefox.
These tests are vendored under _remote/test/puppeteer/_ and are
@ -121,5 +121,48 @@ a Tier-3 class test job theyre not automatically scheduled.
To schedule the tests, look for `source-test-remote-puppeteer` in
`./mach try fuzzy`.
The tests are written in the behaviour-driven testing framework
[Mocha], which doesnt support selecting tests by file path like
other harnesses. It does however come with a myriad of flags to
narrow down the selection a bit: some of the most useful ones include
[`--grep`], [`--ignore`], and [`--file`].
Perhaps the most useful trick is to rename the `describe()` or
`it()` functions to `fdescribe()` and `fit()`, respectively, in
order to run a specific subset of tests. This does however force
you to edit the test files manually.
A real-world example:
```diff
diff --git a/remote/test/puppeteer/test/frame.spec.js b/remote/test/puppeteer/test/frame.spec.js
index 58e57934a7b8..0531d49d7a12 100644
--- a/remote/test/puppeteer/test/frame.spec.js
+++ b/remote/test/puppeteer/test/frame.spec.js
@@ -48,7 +48,7 @@ module.exports.addTests = function({testRunner, expect}) {
});
});
- describe('Frame.evaluateHandle', function() {
+ fdescribe('Frame.evaluateHandle', function() {
it('should work', async({page, server}) => {
await page.goto(server.EMPTY_PAGE);
const mainFrame = page.mainFrame();
@@ -58,7 +58,7 @@ module.exports.addTests = function({testRunner, expect}) {
});
describe('Frame.evaluate', function() {
- it('should throw for detached frames', async({page, server}) => {
+ fit('should throw for detached frames', async({page, server}) => {
const frame1 = await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE);
await utils.detachFrame(page, 'frame1');
let error = null;
```
[Puppeteer test suite]: https://github.com/GoogleChrome/puppeteer/tree/master/test
[track progress]: https://docs.google.com/spreadsheets/d/1GZ4yO2-NGD6kbsT7aMlUPUpUqTaASpqNxJGKhOQ-_BM/edit#gid=0
[Puppeteer support]: https://bugzilla.mozilla.org/show_bug.cgi?id=puppeteer
[Mocha]: https://mochajs.org/
[`--grep`]: https://mochajs.org/#-grep-regexp-g-regexp
[`--ignore`]: https://mochajs.org/#-ignore-filedirectoryglob
[`--file`]: https://mochajs.org/#-file-filedirectoryglob