1 # lsp-test [![Build Status](https://travis-ci.com/bubba/lsp-test.svg?branch=master)](https://travis-ci.com/bubba/lsp-test) [![Hackage](https://img.shields.io/hackage/v/lsp-test.svg)](https://hackage.haskell.org/package/lsp-test-0.1.0.0)
2 lsp-test is a functional testing framework for Language Server Protocol servers.
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
14 ### Unit tests with HSpec
16 describe "diagnostics" $
17 it "report errors" $ runSession "hie" fullCaps "test/data" $ do
18 openDoc "Error.hs" "haskell"
19 [diag] <- waitForDiagnosticsSource "ghcmod"
21 diag ^. severity `shouldBe` Just DsError
22 diag ^. source `shouldBe` Just "ghcmod"
25 ### Replaying captured session
27 replaySession "hie" "test/data/renamePass"
30 ### Parsing with combinators
32 skipManyTill loggingNotification publishDiagnosticsNotification
33 count 4 (message :: Session ApplyWorkspaceEditRequest)
34 anyRequest <|> anyResponse
37 Try out the example tests in the `example` directory with `cabal new-test`.
38 For more examples check the [Wiki](https://github.com/bubba/lsp-test/wiki/Introduction)
41 To test make sure you have the following language servers installed:
42 - [haskell-ide-engine](https://github.com/haskell/haskell-ide-engine)
43 - [javascript-typescript-langserver](https://github.com/sourcegraph/javascript-typescript-langserver)
47 The present tests are integration tests. Thus, it is required that that the executables `hie` and `javascript-typescript-langserver` are on the path.
49 The executable `hie` has to have been built using GHC 8.6.2. This can be done by cloning [Haskell-IDE-Engine](https://github.com/haskell/haskell-ide-engine) and invoking `stack install.hs hie-8.6.2`. This will create the executables `hie`, `hie-8.6` and `hie-8.6.2` in your `$HOME/.local/bin`, or respective `stack path --local-bin` location.
50 To make sure the test environment is identical to the travis setup, in `.travis.yml` you can find the exact git hash that has been used to execute the tests and build `hie` from that snapshot.
52 The language server `javascript-typescript-langserver` can be installed by invoking `npm i -g javascript-typescript-langserver`.
54 When all prerequisites have been met, the tests can be executed by running `stack test`.