Skip to content

Commit 25d2d86

Browse files
author
Serhii Khoma
committed
feat: better output -> wrap each spec in describe
1 parent ff70a3c commit 25d2d86

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Test/Spec/Discovery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function getSpecs(pattern) {
2323
? path.join('file://', __dirname, '..', name, 'index.js')
2424
: path.join(__dirname, '..', name, 'index.js')
2525
return import(fullPath).then(module =>
26-
module && typeof module.spec !== 'undefined' ? module.spec : null
26+
module && typeof module.spec !== 'undefined' ? { name, spec: module.spec } : null
2727
)
2828
})
2929

src/Test/Spec/Discovery.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
module Test.Spec.Discovery
22
( discover
33
, discoverAndRunSpecs
4-
)
5-
where
4+
) where
65

76
import Prelude
87

@@ -12,17 +11,18 @@ import Effect.Aff (launchAff_)
1211
import Effect.Aff.Class (class MonadAff, liftAff)
1312
import Effect.Aff.Compat (EffectFn1, EffectFnAff, fromEffectFnAff, runEffectFn1)
1413
import Effect.Class (liftEffect)
15-
import Test.Spec (Spec)
14+
import Test.Spec (Spec, describe)
1615
import Test.Spec.Runner (Reporter)
1716
import Test.Spec.Runner.Node (runSpecAndExitProcess)
1817

19-
foreign import getSpecs :: EffectFn1 String (EffectFnAff (Array (Spec Unit)))
18+
foreign import getSpecs :: EffectFn1 String (EffectFnAff (Array { name :: String, spec :: Spec Unit }))
2019

2120
discover :: m. MonadAff m => String -> m (Spec Unit)
2221
discover pattern = do
2322
runDiscover <- liftEffect $ runEffectFn1 getSpecs pattern
2423
specs <- liftAff $ fromEffectFnAff runDiscover
25-
pure $ sequence_ specs
24+
let specsWrappedInDescribe = map (\{ name, spec } -> describe name spec) specs
25+
pure $ sequence_ specsWrappedInDescribe
2626

2727
discoverAndRunSpecs :: Array Reporter -> String -> Effect Unit
2828
discoverAndRunSpecs reporters pattern = launchAff_ do

0 commit comments

Comments
 (0)