Closed Bug 1073132 Opened 10 years ago Closed 10 years ago

[Camera] fix camera tests with a newer mocha

Categories

(Firefox OS Graveyard :: Gaia::Camera, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: julienw, Assigned: julienw)

References

Details

Attachments

(1 file)

46 bytes, text/x-github-pull-request
wilsonpage
: review+
Details | Review
In Bug 874510 we want to upgrade mocha to a newer version. Camera tests are failing with the newer mocha:

02:43:12     INFO -  TEST-UNEXPECTED-FAIL | camera/test/unit/lib/camera/camera_test.js | lib/camera/camera Camera#configure() "before each" hook: wrapper - this.mozCamera is null
02:43:12     INFO -      TypeError: this.mozCamera is null
02:43:12     INFO -          at (anonymous) (app://camera.gaiamobile.org/test/unit/lib/camera/camera_test.js:824:7)
02:43:12     INFO -          at wrapper (app://camera.gaiamobile.org/common/test/mocha_generators.js:62:19)
02:43:12     INFO -          at run (app://camera.gaiamobile.org/common/vendor/mocha/mocha.js:4311:7)
02:43:12     INFO -          at next (app://camera.gaiamobile.org/common/vendor/mocha/mocha.js:4613:5)
02:43:12     INFO -          at (anonymous) (app://camera.gaiamobile.org/common/vendor/mocha/mocha.js:4630:5)
02:43:12     INFO -          at timeslice (app://camera.gaiamobile.org/common/vendor/mocha/mocha.js:5763:5)
0

https://tbpl.mozilla.org/php/getParsedLog.php?id=48759080&tree=Gaia-Try#error2

The issue is that with the new mocha "this" is no more shared between all tests/suites. I don't remember the exact rules, but I think a new context is created when creating a nested suite, with the outer context as prototype. Something like: "var nestedContext = Object.create(outerContext)".

So when in the test this is executed: "this.mozCamera = null", it's not reset in the setup.

I fix this simply by running "delete this.mozCamera" instead. This is not the same semantic but this seems to do the trick :)
Assignee: nobody → felash
Attached file github PR
Attachment #8495444 - Flags: review?(wilsonpage)
Attachment #8495444 - Flags: review?(wilsonpage) → review+
master: e9868fe4483f760f8d4ba0b53c31f176f9e084c8
thanks !
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: