question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use `getFakeLogger()` everywhere in the test suite

See original GitHub issue

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,

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
willdurandcommented, Nov 4, 2018

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

1reaction
shristitcommented, Sep 28, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test cases and test suites - IBM
A test suite is a collection of test cases that are grouped for test execution purposes. Test cases. A typical use of test...
Read more >
LLVM Testing Infrastructure Guide - Documentation
The test suite contains whole programs, which are pieces of code which can be compiled and linked into a stand-alone program that can...
Read more >
Interactive Data Public Test Suite - SEC.gov
The purpose of the public test suite is to assist developers of software that must validate Interactive Data prior to its submission to...
Read more >
unittest — Unit testing framework — Python 3.11.1 ...
This is useful when a resource that needs to be set up is not available. Expected failures use the expectedFailure() decorator. class ExpectedFailureTestCase( ......
Read more >
Robot Framework User Guide
This section covers Robot Framework's overall test data syntax. The following sections will explain how to actually create test cases, test suites and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found