Created
February 6, 2019 23:22
-
-
Save colinfwren/ad789b0210253bed8567aae30f9d8613 to your computer and use it in GitHub Desktop.
Couchbase report for jest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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