Skip to content

Commit 920cbec

Browse files
committed
Add trivial entrypoint + update docs
1 parent 1822082 commit 920cbec

File tree

6 files changed

+1678
-1543
lines changed

6 files changed

+1678
-1543
lines changed

CHANGELOG.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## v8.4.0
99

10-
@srghma Use `spec-node` in tests
10+
## Added
11+
12+
- Use `spec-node` in tests by @srghma
13+
- New trivial entrypoint function `discoverAndRunSpecs` for ergonomics by @fsoikin
1114

1215
## v8.0.1
1316

14-
- @CarstenKoenig Fix discovery on Windows by prepending `file://`
17+
## Changed
18+
19+
- Fix discovery on Windows by prepending `file://` by @CarstenKoenig
1520

1621
## v8.0.0
17-
Features:
18-
- Update to v0.15.0 and support es modules
1922

20-
Breaking changes:
21-
- `discover` now needs `MonadAff` constraint instead of `MonadEffect` due to dynamic imports returning promises
23+
## Changed
24+
- Update to v0.15.0 and support es modules
25+
- **breaking** `discover` now needs `MonadAff` constraint instead of `MonadEffect` due to dynamic imports returning promises

README.md

+30-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,35 @@ purescript-spec-discovery is an extension to
44
[purescript-spec](https://github.com/purescript-spec/purescript-spec) that finds
55
specs automatically, given a regular expression pattern.
66

7-
It only works for NodeJS environments, currently.
7+
It only works for NodeJS environments, currently, since it's using NodeJS
8+
facilities to list and load modules.
89

910
## Usage
1011

12+
Install via Spago:
13+
1114
```bash
1215
spago install spec-discovery
1316
```
1417

18+
Use as main entry point:
19+
20+
```purescript
21+
module Test.Main where
22+
23+
import Prelude
24+
import Effect (Effect)
25+
import Test.Spec.Discovery (discoverAndRunSpec)
26+
import Test.Spec.Reporter.Console (consoleReporter)
27+
28+
main :: Effect Unit
29+
main = discoverAndRunSpecs [consoleReporter] """My\.Package\..*Spec"""
30+
```
31+
32+
Or, if you need more sophistication, like an alternative config or whatnot, use
33+
the `discover` function to just return a list of specs and then run them in
34+
whatever way you need:
35+
1536
```purescript
1637
module Test.Main where
1738
@@ -20,21 +41,23 @@ import Effect (Effect)
2041
import Effect.Aff (launchAff_)
2142
import Test.Spec.Discovery (discover)
2243
import Test.Spec.Reporter.Console (consoleReporter)
23-
import Test.Spec.Runner (runSpec)
44+
import Test.Spec.Runner.Node (runSpecAndExitProcess)
45+
import Test.Spec.Runner.Node.Config (defaultConfig)
2446
2547
main :: Effect Unit
2648
main = launchAff_ do
2749
specs <- discover """My\.Package\..*Spec"""
28-
runSpec [consoleReporter] specs
50+
liftEffect $ runSpecAndExitProcess'
51+
{ defaultConfig: defaultConfig { timeout = Nothing }
52+
, parseCLIOptions: true
53+
}
54+
[consoleReporter]
55+
specs
2956
```
3057

3158
All modules that match the regular expression, **and have a definition
3259
`spec :: Spec Unit`**, will be included and run.
3360

34-
## Documentation
35-
36-
Documentation is publised on [Pursuit](https://pursuit.purescript.org/packages/purescript-spec-discovery).
37-
3861
## Contribute
3962

4063
If you have any issues or possible improvements please file them as

0 commit comments

Comments
 (0)