
Product
Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.
@sourcegraph/extension-api-stubs
Advanced tools
Stubs for the Sourcegraph extension API to unit-test Sourcegraph extensions
Sourcegraph extensions have been deprecated with the September 2022 Sourcegraph release. Learn more.
The repo and the docs below are kept to support older Sourcegraph versions.
Stubs for the Sourcegraph extension API to unit-test Sourcegraph extensions
npm install @sourcegraph/extension-api-stubs
# or
yarn add @sourcegraph/extension-api-stubs
import mock from 'mock-require'
import { createStubSourcegraphAPI, createStubExtensionContext } from '@sourcegraph/extension-api-stubs'
const sourcegraph = createStubSourcegraphAPI()
// For modules importing Range/Location/Position/URI/etc
mock('sourcegraph', sourcegraph)
import * as sinon from 'sinon'
import { activate } from './extension'
describe('my extension', () => {
it('should register a hover provider', async () => {
const context = createStubExtensionContext()
await activate(context)
sinon.assert.calledOnce(sourcegraph.languages.registerHoverProvider)
const provider = sourcegraph.languages.registerHoverProvider.args[0][1]
const result = provider()
// More assertions ...
})
})
See the Sinon documentation for more info on how to use the stubs.
yarn
yarn build
yarn test
Releases are done automatically in CI when commits are merged into master by analyzing Conventional Commit Messages.
After running yarn, commit messages will be linted automatically when committing though a git hook.
The git hook can be circumvented for fixup commits with git's fixup! autosquash feature, or by passing --no-verify to git commit.
You may have to rebase a branch before merging to ensure it has a proper commit history, or squash merge with a manually edited commit message that conforms to the convention.
FAQs
Stubs for the Sourcegraph extension API to unit-test Sourcegraph extensions
The npm package @sourcegraph/extension-api-stubs receives a total of 625 weekly downloads. As such, @sourcegraph/extension-api-stubs popularity was classified as not popular.
We found that @sourcegraph/extension-api-stubs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.