Skip to content

Instantly share code, notes, and snippets.

@colinfwren
Created February 6, 2019 23:22
Show Gist options
  • Save colinfwren/ad789b0210253bed8567aae30f9d8613 to your computer and use it in GitHub Desktop.
Save colinfwren/ad789b0210253bed8567aae30f9d8613 to your computer and use it in GitHub Desktop.
Couchbase report for jest
var couchbase = require('couchbase');
class CouchbaseReporter {
constructor(globalConfig, options) {
this._globalConfig = globalConfig;
this._options = options;
const cluster = new couchbase.Cluster(`couchbase://127.0.0.1`);
cluster.authenticate('genericUser', 'dontStealMe');
this.bucket = cluster.openBucket('default');
}
onRunStart({ numTotalTestSuites }) {
console.log(`[couchbaseReporter] Found ${numTotalTestSuites} test suites.`);
}
onRunComplete(test, results) {
const testRunId = process.env.TEST_RUN_ID;
if (typeof (testRunId) === 'undefined') {
throw new Error('No test run ID passed');
}
const bucket = this.bucket;
bucket.upsert(testRunId, results, function(err, result) {
if (err) throw err;
bucket.disconnect();
});
}
}
module.exports = CouchbaseReporter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment