Addons-frontend: Use `getFakeLogger()` everywhere in the test suite

Created on 26 Sep 2018  路  7Comments  路  Source: mozilla/addons-frontend

A getFakeLogger() helper has been introduced in https://github.com/mozilla/addons-frontend/pull/6378, we should use it everywhere now.

There are several occurrences to replace with different names, including:

  • fakeLog:
tests/unit/core/test_tracking.js:      const fakeLog = { info: sinon.stub() };
tests/unit/core/test_tracking.js:        _log: fakeLog,
tests/unit/core/test_tracking.js:      sinon.assert.calledWith(fakeLog.info, 'Do Not Track is enabled');
tests/unit/core/test_tracking.js:      fakeLog.info.resetHistory();
tests/unit/core/test_tracking.js:        _log: fakeLog,
tests/unit/core/test_tracking.js:      sinon.assert.calledWith(fakeLog.info, 'Do Not Track is enabled');
tests/unit/amo/components/TestAddonCompatibilityError.js:    const fakeLog = { warn: sinon.stub() };
tests/unit/amo/components/TestAddonCompatibilityError.js:      log: fakeLog,
tests/unit/amo/components/TestAddonCompatibilityError.js:      fakeLog.warn,
tests/unit/core/utils/test_compatibility.js:      const fakeLog = { error: sinon.stub() };
tests/unit/core/utils/test_compatibility.js:          _log: fakeLog,
tests/unit/core/utils/test_compatibility.js:      expect(fakeLog.error.firstCall.args[0]).toContain(
tests/unit/core/sagas/test_utils.js:    const fakeLog = { error: sinon.stub() };
tests/unit/core/sagas/test_utils.js:      log: fakeLog,
tests/unit/core/sagas/test_utils.js:      fakeLog.error,
tests/unit/core/components/TestAMInstallButton.js:    const fakeLog = { info: sinon.stub() };
tests/unit/core/components/TestAMInstallButton.js:      _log: fakeLog,
tests/unit/core/components/TestAMInstallButton.js:    sinon.assert.calledWith(fakeLog.info, 'Adding OpenSearch Provider');
tests/unit/core/components/TestInstallButton.js:    const fakeLog = { info: sinon.stub() };
tests/unit/core/components/TestInstallButton.js:      _log: fakeLog,
tests/unit/core/components/TestInstallButton.js:    sinon.assert.calledWith(fakeLog.info, 'Adding OpenSearch Provider');
tests/unit/core/i18n/test_utils.js:      const fakeLog = {
tests/unit/core/i18n/test_utils.js:      utils.langToLocale('whatevs-this-is-really-odd', fakeLog);
tests/unit/core/i18n/test_utils.js:      sinon.assert.called(fakeLog.error);
tests/unit/core/i18n/test_utils.js:      const fakeLog = {
tests/unit/core/i18n/test_utils.js:      utils.localeToLang('what_the_heck_is_this', fakeLog);
tests/unit/core/i18n/test_utils.js:      sinon.assert.called(fakeLog.error);
  • _log:
tests/unit/core/test_addonManager.js:      const _log = {
tests/unit/core/test_addonManager.js:        { _log },
tests/unit/core/test_addonManager.js:      sinon.assert.notCalled(_log.error);
tests/unit/core/test_addonManager.js:      const _log = {
tests/unit/core/test_addonManager.js:        { _log },
tests/unit/core/test_addonManager.js:      sinon.assert.calledOnce(_log.error);
tests/unit/core/test_tracking.js:        _log: fakeLog,
tests/unit/core/test_tracking.js:        _log: fakeLog,
tests/unit/core/middleware/test_cspMiddleware.js:        _log: {
tests/unit/core/middleware/test_cspMiddleware.js:        _log: {
tests/unit/core/middleware/test_cspMiddleware.js:      const _log = { debug: sinon.spy() };
tests/unit/core/middleware/test_cspMiddleware.js:        _log,
tests/unit/core/middleware/test_cspMiddleware.js:      sinon.assert.calledOnce(_log.debug);
tests/unit/core/middleware/test_datadogTiming.js:      const _log = { error: sinon.stub() };
tests/unit/core/middleware/test_datadogTiming.js:      datadogTiming({ _log, _HotShots: StubHotShots });
tests/unit/core/middleware/test_datadogTiming.js:      sinon.assert.calledWith(_log.error, sinon.match(error.message));
tests/unit/core/middleware/test_datadogTiming.js:      sinon.assert.calledWithMatch(_log.error, { err: error });
tests/unit/core/utils/test_compatibility.js:          _log: fakeLog,
tests/unit/core/utils/test_server.js:      const _log = {
tests/unit/core/utils/test_server.js:      const handler = viewFrontendVersionHandler({ _config, _log });
tests/unit/core/utils/test_server.js:        sinon.assert.calledOnce(_log.error);
tests/unit/core/components/TestAMInstallButton.js:      _log: fakeLog,
tests/unit/core/components/TestInstallButton.js:      _log: fakeLog,
tests/unit/core/api/test_index.js:      const _log = {
tests/unit/core/api/test_index.js:      await api.callApi({ endpoint: 'resource', _log });
tests/unit/core/api/test_index.js:        _log.warn,
code quality assigned good first bug mentor assigned welcome p4 not needed

Most helpful comment

Thanks for your first contribution @akshitkrnagpal! /cc @caitmuenster

All 7 comments

Hi @willdurand i would like to work on it , can you tell me how to proceed? . As you mentioned here i replaced fakelog & _log with getFakeLogger but test cases are failing locally

@shristit I would love to help out whilst we wait for Will - can you open a PR wth a WIP message that contains the work that you've done so far? It'll be easier for everyone to get involved once we can see what's giving you trouble 馃榿 馃檶馃徑

If you have any questions, please feel free to ask!!

Mentor: @willdurand

@willdurand
I am new to this project and would like to take this. 馃槃
Can you assign this to me?

Thanks for your first contribution @akshitkrnagpal! /cc @caitmuenster

@willdurand Is there something qa should check for this issue?
Thanks!

nope, thanks!

Was this page helpful?
0 / 5 - 0 ratings