Skip to content

Commit

Permalink
Add trivial entrypoint + update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoikin committed Oct 7, 2024
1 parent 1822082 commit 7ea1f04
Show file tree
Hide file tree
Showing 6 changed files with 1,738 additions and 1,539 deletions.
18 changes: 11 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## v8.4.0

@srghma Use `spec-node` in tests
## Added

- Use `spec-node` in tests by @srghma
- New trivial entrypoint function `discoverAndRunSpecs` for ergonomics by @fsoikin

## v8.0.1

- @CarstenKoenig Fix discovery on Windows by prepending `file://`
## Changed

- Fix discovery on Windows by prepending `file://` by @CarstenKoenig

## v8.0.0
Features:
- Update to v0.15.0 and support es modules

Breaking changes:
- `discover` now needs `MonadAff` constraint instead of `MonadEffect` due to dynamic imports returning promises
## Changed
- Update to v0.15.0 and support es modules
- **breaking** `discover` now needs `MonadAff` constraint instead of `MonadEffect` due to dynamic imports returning promises
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,35 @@ purescript-spec-discovery is an extension to
[purescript-spec](https://github.com/purescript-spec/purescript-spec) that finds
specs automatically, given a regular expression pattern.

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

## Usage

Install via Spago:

```bash
spago install spec-discovery
```

Use as main entry point:

```purescript
module Test.Main where
import Prelude
import Effect (Effect)
import Test.Spec.Discovery (discoverAndRunSpec)
import Test.Spec.Reporter.Console (consoleReporter)
main :: Effect Unit
main = discoverAndRunSpecs [consoleReporter] """My\.Package\..*Spec"""
```

Or, if you need more sophistication, like an alternative config or whatnot, use
the `discover` function to just return a list of specs and then run them in
whatever way you need:

```purescript
module Test.Main where
Expand All @@ -20,21 +41,23 @@ import Effect (Effect)
import Effect.Aff (launchAff_)
import Test.Spec.Discovery (discover)
import Test.Spec.Reporter.Console (consoleReporter)
import Test.Spec.Runner (runSpec)
import Test.Spec.Runner.Node (runSpecAndExitProcess)
import Test.Spec.Runner.Node.Config (defaultConfig)
main :: Effect Unit
main = launchAff_ do
specs <- discover """My\.Package\..*Spec"""
runSpec [consoleReporter] specs
liftEffect $ runSpecAndExitProcess'
{ defaultConfig: defaultConfig { timeout = Nothing }
, parseCLIOptions: true
}
[consoleReporter]
specs
```

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

## Documentation

Documentation is publised on [Pursuit](https://pursuit.purescript.org/packages/purescript-spec-discovery).

## Contribute

If you have any issues or possible improvements please file them as
Expand Down
Loading

0 comments on commit 7ea1f04

Please sign in to comment.