Open Bug 1767976 Opened 3 years ago Updated 1 year ago

Improve the mochitest doc wrt add_task

Categories

(Testing :: Mochitest, enhancement)

x86_64
Linux
enhancement

Tracking

(Not tracked)

People

(Reporter: u695164, Unassigned)

References

()

Details

URL = https://firefox-source-docs.mozilla.org/testing/mochitest-plain/faq.html

I think this is a good place to describe that for mochitests the function parameters are slightly different to xpcshell-tests

add_task(testFunc) is possible but not
add_task([condition, ]testFunc)

Something like this could help:

Please use add_task(testFunc).skip(condition)

James, what do you think about this ?
thanks

Flags: needinfo?(james)

I'm not the mochiest expert, but I think that ought to be added to https://firefox-source-docs.mozilla.org/testing/mochitest-plain/index.html#asynchronous-tests since that documents add_task.

Flags: needinfo?(james) → needinfo?(ahal)

Yeah makes sense to me, maybe in a .. note:: directive.

Flags: needinfo?(ahal)
Component: Firefox Source Docs: Content → Mochitest
Product: Developer Infrastructure → Testing
Summary: Documentation issue on testing/mochitest-plain/faq add_task → Improve the mochitest doc wrt add_task

Just came across this ticket. As a fairly new employee of Mozilla, I was so eager to find out what the function signature is for add_task in our test files. But it appears to be a global variable from somewhere. Would it be worth adding the documentation to the function using JSDoc and allowing us to explicitly import the add_task function into the file like below?

Having an explicit import would not only make it clear which of the add_task functions is being executed. But it would also help with intellisense in our IDE.

e.g.

<!DOCTYPE HTML>
<html>
<body>
<script>
import { add_task } from '../path/to/the/file.js';
add_task(async () => {
  // code here
});
</script>
</body>
</html>
You need to log in before you can comment on or make changes to this bug.