s/haskell-lsp-test/lsp-test
[lsp-test.git] / README.md
1 # lsp-test [![Build Status](https://travis-ci.com/Bubba/haskell-lsp-test.svg?branch=master)](https://travis-ci.com/Bubba/haskell-lsp-test)
2 lsp-test is a functional testing framework for Language Server Protocol servers.
3
4 ```haskell
5 import Language.Haskell.LSP.Test
6 runSession "hie" fullCaps "proj/dir" $ do
7   doc <- openDoc "Foo.hs" "haskell"
8   skipMany anyNotification
9   symbols <- getDocumentSymbols doc
10 ```
11
12 ## Examples
13
14 ### Unit tests with HSpec
15 ```haskell
16 describe "diagnostics" $
17   it "report errors" $ runSession "hie" fullCaps "test/data" $ do
18     openDoc "Error.hs" "haskell"
19     [diag] <- waitForDiagnosticsSource "ghcmod"
20     liftIO $ do
21       diag ^. severity `shouldBe` Just DsError
22       diag ^. source `shouldBe` Just "ghcmod"
23 ```
24
25 ### Replaying captured session
26 ```haskell
27 replaySession "hie" "test/data/renamePass"
28 ```
29
30 ### Parsing with combinators
31 ```haskell
32 skipManyTill loggingNotification publishDiagnosticsNotification
33 count 4 (message :: Session ApplyWorkspaceEditRequest)
34 anyRequest <|> anyResponse
35 ```
36
37 For more examples check the [Wiki](https://github.com/Bubba/haskell-lsp-test/wiki/Introduction)
38
39 ## Developing
40 To test make sure you have the following language servers installed:
41 - [haskell-ide-engine](https://github.com/haskell/haskell-ide-engine)
42 - [javascript-typescript-langserver](https://github.com/sourcegraph/javascript-typescript-langserver)