Skip to content

feat: better output -> wrap each spec in describe #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Test/Spec/Discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function getSpecs(pattern) {
? path.join('file://', __dirname, '..', name, 'index.js')
: path.join(__dirname, '..', name, 'index.js')
return import(fullPath).then(module =>
module && typeof module.spec !== 'undefined' ? module.spec : null
module && typeof module.spec !== 'undefined' ? { name, spec: module.spec } : null
)
})

Expand Down
9 changes: 4 additions & 5 deletions src/Test/Spec/Discovery.purs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module Test.Spec.Discovery
( discover
, discoverAndRunSpecs
)
where
) where

import Prelude

Expand All @@ -12,17 +11,17 @@ import Effect.Aff (launchAff_)
import Effect.Aff.Class (class MonadAff, liftAff)
import Effect.Aff.Compat (EffectFn1, EffectFnAff, fromEffectFnAff, runEffectFn1)
import Effect.Class (liftEffect)
import Test.Spec (Spec)
import Test.Spec (Spec, describe)
import Test.Spec.Runner (Reporter)
import Test.Spec.Runner.Node (runSpecAndExitProcess)

foreign import getSpecs :: EffectFn1 String (EffectFnAff (Array (Spec Unit)))
foreign import getSpecs :: EffectFn1 String (EffectFnAff (Array { name :: String, spec :: Spec Unit }))

discover :: ∀ m. MonadAff m => String -> m (Spec Unit)
discover pattern = do
runDiscover <- liftEffect $ runEffectFn1 getSpecs pattern
specs <- liftAff $ fromEffectFnAff runDiscover
pure $ sequence_ specs
pure $ sequence_ $ specs <#> \{ name, spec } -> describe name spec

discoverAndRunSpecs :: Array Reporter -> String -> Effect Unit
discoverAndRunSpecs reporters pattern = launchAff_ do
Expand Down