polendina
Version:
Non-UI browser testing for JavaScript libraries from the command-line
15 lines (12 loc) • 610 B
JavaScript
/* globals WorkerGlobalScope ServiceWorkerGlobalScope */
const { assert } = require('chai')
if (typeof ServiceWorkerGlobalScope !== 'undefined' && global instanceof ServiceWorkerGlobalScope) {
console.log('testing is in serviceworker')
assert.strictEqual(typeof ServiceWorkerGlobalScope, 'function')
} else if (typeof WorkerGlobalScope !== 'undefined' && global instanceof WorkerGlobalScope) {
console.log('testing is in worker')
assert.strictEqual(typeof WorkerGlobalScope, 'function')
} else {
console.log('testing is not in worker')
assert.strictEqual(typeof WorkerGlobalScope, 'undefined')
}