@sourcegraph/extension-api-stubs
    TypeScript icon, indicating that this package has built-in type declarations

    1.6.1 • Public • Published

    @sourcegraph/extension-api-stubs

    npm downloads master build status codecov code style: prettier semantic-release

    Stubs for the Sourcegraph extension API to unit-test Sourcegraph extensions

    Install

    npm install @sourcegraph/extension-api-stubs
    # or
    yarn add @sourcegraph/extension-api-stubs
    

    Example

    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.

    Build

    yarn
    yarn build
    

    Test

    yarn test
    

    Release

    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.

    Keywords

    none

    Install

    npm i @sourcegraph/extension-api-stubs

    DownloadsWeekly Downloads

    589

    Version

    1.6.1

    License

    MIT

    Unpacked Size

    48.9 kB

    Total Files

    47

    Last publish

    Collaborators

    • sourcegraph-bot
    • sqs
    • beyang
    • nicksnyder
    • felixfbecker
    • slimsag
    • attfarhan
    • dadlerj
    • ggilmore
    • keegancsmith
    • vanesa-
    • lguychard
    • efritz
    • garosrc
    • 5h1ru
    • roksg