Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quibble

Package Overview
Dependencies
Maintainers
3
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quibble - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

2

example-esm/package-lock.json

@@ -15,3 +15,3 @@ {

"..": {
"version": "0.7.0",
"version": "0.8.0",
"dev": true,

@@ -18,0 +18,0 @@ "license": "MIT",

@@ -15,3 +15,3 @@ {

"..": {
"version": "0.7.0",
"version": "0.8.0",
"dev": true,

@@ -18,0 +18,0 @@ "license": "MIT",

@@ -122,2 +122,9 @@ const Module = require('module')

quibble.listMockedModules = function () {
const esmMockedModules = quibbleUserToLoaderCommunication()?.listMockedModules() ?? []
const cjsMockedModules = Object.keys(quibbles).map((modulePath) => pathToFileURL(modulePath).href)
return esmMockedModules.concat(cjsMockedModules)
}
quibble.isLoaderLoaded = function () {

@@ -124,0 +131,0 @@ return !!quibbleUserToLoaderCommunication()

@@ -19,3 +19,3 @@ exports.thisWillRunInUserThread = (globalThis, port) => {

},
async addMockedModule (
addMockedModule (
moduleUrl,

@@ -49,2 +49,25 @@ { namedExportStubs, defaultExportStub }

}
},
listMockedModules () {
if (!loaderAndUserRunInSameThread(globalThis)) {
const hasListMockedModulesHappened = new Int32Array(new SharedArrayBuffer(4))
const mockedModulesListLength = new Int32Array(new SharedArrayBuffer(4))
const mockedModulesList = new Uint8Array(new SharedArrayBuffer(20 * 1024 * 1024)) // 20MB should be sufficient
port.postMessage({
type: 'listMockedModules',
hasListMockedModulesHappened,
mockedModulesListLength,
mockedModulesList
})
Atomics.wait(hasListMockedModulesHappened, 0, 0)
if (mockedModulesListLength[0] > mockedModulesList.length) {
throw new Error('Not enough buffer allocated for result')
}
const serializedMockedModules = new TextDecoder().decode(mockedModulesList.slice(0, mockedModulesListLength[0]))
return serializedMockedModules ? serializedMockedModules.split(' ') : []
} else {
const quibbleLoaderState = globalThis[Symbol.for('__quibbleLoaderState')]
return Array.from(quibbleLoaderState.quibbledModules.keys())
}
}

@@ -51,0 +74,0 @@ }

{
"name": "quibble",
"version": "0.8.0",
"version": "0.9.0",
"description": "Makes it easy to replace require'd dependencies.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/testdouble/quibble",

const quibble = require('../../lib/quibble')
const { pathToFileURL } = require('url')

@@ -130,2 +131,20 @@ module.exports = {

},
'list mocked modules': async function () {
quibble('../fixtures/a-function', function () { return 'kek' })
assert.deepEqual(quibble.listMockedModules(), [
pathToFileURL(quibble.absolutify('../fixtures/a-function', __filename)).href
])
quibble('../fixtures/b-function', function () { return 'kek' })
assert.deepEqual(quibble.listMockedModules(), [
pathToFileURL(quibble.absolutify('../fixtures/a-function', __filename)).href,
pathToFileURL(quibble.absolutify('../fixtures/b-function', __filename)).href
])
quibble.reset()
assert.deepEqual(await quibble.listMockedModules(), [])
},
afterEach: function () {

@@ -132,0 +151,0 @@ quibble.reset()

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc