Open Bug 1524027 Opened 2 years ago Updated 2 years ago

Provide alternative to module exports for testing purposes

Categories

(Toolkit :: General, enhancement, P3)

65 Branch
enhancement

Tracking

()

People

(Reporter: zombie, Unassigned)

References

(Blocks 2 open bugs)

Details

After bug 1432901 or thereabouts, only explicitly exported symbols from the module will be available to importers. We need a solution for symbols used in testing, but which we don't want to make part of the module exports.

My proposal was to agree on a convention like TEST_ONLY export symbol, and use eslint (or code in the importer) to ensure it's not used outside of tests. That would have the advantage of aligning with existing JS tooling.


Kris wants a more explicit API instead of a convention, so he proposes something like:

Cu.exportBackstage({ mockFoo, mockBar });

from inside the module, and corresponding:

const { mockFoo } = Cu.importBackstage("FooBar.jsm");

from test code.

Priority: -- → P3
Product: Firefox → Toolkit
You need to log in before you can comment on or make changes to this bug.