Skip to content

Instantly share code, notes, and snippets.

@jrgm
Last active December 14, 2015 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrgm/5002316 to your computer and use it in GitHub Desktop.
Save jrgm/5002316 to your computer and use it in GitHub Desktop.
decouple mozilla/browserid/automation-tests from having to require a full npm install of browserid in the parent directory. (automation-tests usage of lib/wsapi-client.js is simply as a client for saucelabs API). (Update: this won't work long term when we really need api versioning)
diff --git a/lib/wsapi_client.js b/lib/wsapi_client.js
index 3531810..ad9ea09 100644
--- a/lib/wsapi_client.js
+++ b/lib/wsapi_client.js
@@ -13,8 +13,26 @@ const
http = require('http'),
https = require('https'),
url = require('url'),
-querystring = require('querystring'),
-version = require('./version.js');
+querystring = require('querystring');
+
+// automation-tests needs wsapi-client to talk to saucelabs. But the
+// ./lib/version.js wrapper is not relevant in this context. This decouples
+// automation-tests/scripts/run-all.js from needing to have a full npm install
+// of browserid in the parent directory.
+//
+// Note to self: To find coupling do `NODE_DEBUG=module ./scripts/run-all.js
+// ...`, and, um, then look for where a load from browserid/node_modules
+// begins to enter the sequence.
+
+var version;
+if (process.env.AUTOMATION_TESTS) {
+ version = function(callback) {
+ callback('deadbee');
+ };
+}
+else {
+ version = require('./version.js');
+}
// this client library keeps timing stats to allow higher level code
// (like loadgen) to output latency numbers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment