Skip to content
This repository has been archived by the owner on Aug 10, 2018. It is now read-only.

Implement Automated Testing #113

Open
8 tasks
simonwex opened this issue Mar 4, 2015 · 2 comments
Open
8 tasks

Implement Automated Testing #113

simonwex opened this issue Mar 4, 2015 · 2 comments

Comments

@simonwex
Copy link

simonwex commented Mar 4, 2015

  • Implement testing framework
  • Pick two recent or open bugs
    • Bug: ____
    • Bug: ____
  • implement tests that validate fixes for two open bugs
  • Document how to add a new test
  • Set up project on TravisCI
  • Add Travis status Image to README
  • Add mofo-style linter
  • Ensure all tests are passing

MozillaFoundation/plan#351

@simonwex simonwex added this to the March 13, 2015 milestone Mar 4, 2015
@Pomax
Copy link

Pomax commented Mar 10, 2015

There is an interesting problem with newrelic here: the testing with mocha works quite well provided either newrellic is available, or a newrelic shim is used in event-controller.js. However, I cannot seem to find any particular way to reliably detect whether newrelic will work and then fallback to the shim. Mocha does throw-interceptions that cause the following code to just crash the mocha run:

var newrelic;
try {
  newrelic = require("newrelic");
} catch (err) {
  if (process.env.NODE_ENV === "development") {
    newrelic = {
      addCustomParameter: function() {
        // no need to do anything
      }
    };
  } else {
    throw err;
  }
}

Mind you, this is the same trick we already use in server.js, but because things are wrapped by Mocha, this trick no longer works. The throw from the require call outright terminates the mocha run.

@Pomax
Copy link

Pomax commented Mar 10, 2015

as it turns out, newrelic does not throw errors on require() (any throws it generates it self-catches and simply logs instead), so the try/catch we're using in server.js doesn't even do anything (tested that hypothesis, confirmed it by the catch block never actually running).

So, I'm going to solve this with a new, backward-compatible .env variable called WITHOUT_NEW_RELIC which, when set, effectis loading of a newrelic shim instead of the actual newrelic module.

@Pomax Pomax removed their assignment Jun 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants