A functional test framework for LSP servers
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example Move example to separate cabal file Aug 1, 2018
src/Language/Haskell/LSP Upgrade to haskell-lsp 0.8.0.0 Sep 8, 2018
test Upgrade to haskell-lsp 0.8.0.0 Sep 8, 2018
.gitignore Squashed commit of the following: Aug 14, 2018
.travis.yml Increase cache timeout Sep 9, 2018
ChangeLog.md Add getCodeActions, getCurrentDiagnostics, bump Aug 14, 2018
LICENSE Initial commit May 16, 2018
README.md Update README.md Sep 9, 2018
Setup.hs Initial commit May 16, 2018
lsp-test.cabal
stack.yaml Upgrade to haskell-lsp 0.8.0.0 Sep 8, 2018

README.md

lsp-test Build Status Hackage

lsp-test is a functional testing framework for Language Server Protocol servers.

import Language.Haskell.LSP.Test
runSession "hie" fullCaps "proj/dir" $ do
  doc <- openDoc "Foo.hs" "haskell"
  skipMany anyNotification
  symbols <- getDocumentSymbols doc

Examples

Unit tests with HSpec

describe "diagnostics" $
  it "report errors" $ runSession "hie" fullCaps "test/data" $ do
    openDoc "Error.hs" "haskell"
    [diag] <- waitForDiagnosticsSource "ghcmod"
    liftIO $ do
      diag ^. severity `shouldBe` Just DsError
      diag ^. source `shouldBe` Just "ghcmod"

Replaying captured session

replaySession "hie" "test/data/renamePass"

Parsing with combinators

skipManyTill loggingNotification publishDiagnosticsNotification
count 4 (message :: Session ApplyWorkspaceEditRequest)
anyRequest <|> anyResponse

Try out the example tests in the example directory with cabal new-test. For more examples check the Wiki

Developing

To test make sure you have the following language servers installed: