mozilla / addons

☂ Umbrella repository for Mozilla Addons ✨
Other
125 stars 41 forks source link

Use `getFakeLogger()` everywhere in the test suite #12431

Closed willdurand closed 5 years ago

willdurand commented 5 years ago

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:

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);
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,
shristit commented 5 years ago

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

seanprashad commented 5 years ago

@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!!

jvillalobos commented 5 years ago

Mentor: @willdurand

akshitkrnagpal commented 5 years ago

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

willdurand commented 5 years ago

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

ioanarusiczki commented 5 years ago

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

willdurand commented 5 years ago

nope, thanks!