elm-explorations / elm-explorations/test

Support nested `Test.only`

Open
#128 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elm
Stars
244
Forks
40
Avg merge
1d 23h
Merged PRs (30d)
2

Description

## Problem

Test.only is ignored when nested under something that already has `Test.only` on it.

Use-case/Motivation:
I tend to use `Test.only` to focus on a specific subset of problems. Sometimes I do that on an isolated group of tests that deal with a certain part of a problem. Then, sometimes I have trouble understanding what is happening and I add `Debug.log` calls to gather information. I then sometimes want to focus on a single test to see only the logs that pertain to it. I then usually add another `Test.only` on that test, which is then ignored because a parent `describe` already has `Test.only` applied to it.

This is for me a recurring problem, as I tend to often do tests this way.

## SSCCE

I have three tests in this example. I expect only the one named `"should run and does"` to run, but I also see the one `"should not run but does"` being run.

```elm
module SomeTest exposing (tests)

import Expect
import Test exposing (Test, describe, test)

tests : Test
tests =
describe "Tests"
[ test "should not run and doesn't" <| \() -> Expect.equal 1 2
, Test.only <|
describe "Sub tests"
[ test "should not run but does" <| \() -> Expect.equal 1 2
, Test.only <| test "should run and does" <| \() -> Expect.equal 1 2
]
]
```

```
↓ SomeTest
↓ Tests
↓ Sub tests
✗ should not run but does

2

│ Expect.equal

1

↓ SomeTest
↓ Tests
↓ Sub tests
✗ should run and does

2

│ Expect.equal

1

TEST RUN FAILED

Duration: 147 ms
Passed: 0
Failed: 2
```

### Additional notes

Any occasion is good to thank you for all your work on the tool, so thank you all :heart:

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.