Closed Bug 1546341 Opened 9 months ago Closed 8 months ago

[remote-dbg-next] error running jest with localization

Categories

(DevTools :: about:debugging, task, P3)

task

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ogasidlo, Unassigned)

References

Details

(Whiteboard: remote-debugging-technical-debt )

Attachments

(1 obsolete file)

Follow up for 1520142

While running the Jest test and all tests pass, we get the following error message caused by Localization:

console.error node_modules/prop-types/checkPropTypes.js:20
    Warning: Failed context type: The l10n context field must be an instance of ReactLocalization.
        in Localized
        in button
        in aside
        in Message

STR:

  1. move to the Jest folder in devtools/client/aboutdebugging-new/test/jest
  2. run yarn install
  3. run yarn test

This is caused by fluent-react and we probably need shallow rendering provided by Enzyme here because:

Right now we use fluent with jest that creates a jest snapshot by grabbing the object and parsing it to the snapshot in JSON. As we do not render anything, the Localization id is not being replaced.

Mocking fluent inside the test seems like big overhead.

Flags: needinfo?(stas)
Type: defect → task
Priority: -- → P3

After talking to Staś, using the shallow render method is what we want.
So using Enzyme with Jest is the right way to go.

We also just want to test the Localization IDs (not the strings) as Fluent is taking care of the rest.

Flags: needinfo?(stas)

Closing as information was provided.
If you'd like to take a look at the fixing patch, please check 1548465

Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED

Comment on attachment 9068710 [details]
Bug 1546341 - Fix jest tests with localization, r=ladybenko!,jdescottes!

Revision D33160 was moved to bug 1548465. Setting attachment 9068710 [details] to obsolete.

Attachment #9068710 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.