Ava: Add ability to run a test residing on a given line

Created on 23 May 2019  ·  16Comments  ·  Source: avajs/ava


Issuehunt badges

We currently have --match for running specific tests with titles matching a pattern, but sometimes you're in your editor and you just want to quickly run the test you're working on. --match comes with the overhead of having to think about the pattern and comes with the risk of matching other tests if you're not specific enough.

Would be great to just be able to take the line number and run the test from that information.

Example:

$ ava test/foo.js:3

Where 3 is the line number of the test. The line number could be be any part of the test method:

1: test('foo', t => {
2:   t.true(true);
3: });

So using both line number 1, 2, and 3 should work.

It should be possible to do this with multiple test files too:

$ ava test/foo.js:3 test/bar.js:22

If a path ends with :\d+, it should not be run through glob resolution.

I got the inspiration from https://blog.bigbinary.com/2016/01/03/test-runner-in-rails-5.html, wrote it down, and forget to open an issue about it until now.

This functionality would also open the opportunity for our editor plugins to have a "Run test at the current line" command, which would be super useful. I'll open an issue about that on the editor plugins if this issue is accepted.




IssueHunt Summary

ulken ulken has been rewarded.

Backers (Total: $200.00)

Submitted pull Requests

- #2300 Run tests at selected line numbers

Tips


Rewarded on Issuehunt enhancement help wanted scheduling

All 16 comments

Sounds good. I suppose we would know that a specific line is selected. How would we determine what test sits on what line though?

Would you be able to specify multiple lines?

If a path ends with :\d+, it should not be run through glob resolution.

As of 2.0, AVA now expects file paths on the CLI, not glob patterns.

How would we determine what test sits on what line though?

Each test could save their line number range: https://github.com/sindresorhus/callsites

Would you be able to specify multiple lines?

👍 We could even support multiple ranges: $ ava test.js:4-45,345-500 or $ ava test.js:4-45:345-500.

@issuehunt has funded $200.00 to this issue.


I'm working on this and will send a PR in the upcoming days :)

I'm working on this and will send a PR in the upcoming days :)

@qti3e great!

@novemberborn What's the status on this? Can I take a shot at it?

Yep go for it @ulken. Have a look at https://github.com/avajs/ava/pull/2181 for @qti3e's approach.

@novemberborn Alright, I've opened a draft PR, if you want to start to have a look at it.

I've yet to add description of what's actually been done and not and why* in PR + docs (CLI usage, readme/recipe, 05-command-line.md etc.).

* Meanwhile, commit message descriptions should help out

Cheers @ulken — I probably won't have time to check it out until the weekend though.

Aye, no worries. I’ll make sure to add the docs also before then.

Is this something that is up for grabs? If so, I'd be pleased to take this on @novemberborn

@DonnieWest maybe you could pick up where @ulken left off? If that's OK with you @ulken? https://github.com/avajs/ava/pull/2300

@DonnieWest @novemberborn Let me have a quick look at it. I'll get back to you by the end of the day if I'm up for it or not. My guess is not, but just want to double check the changes that have been made and what's being requested. Thanks!

(Sorry for not replying earlier)

Hey @DonnieWest. I've looked at it now and depending on @novemberborn's view on my feedback, I might be able to pick this up again. I'll let you know as soon as he replies.

@DonnieWest Alright, I'll have a final go at this. I'll make sure to let you know if I'm unable to pull it off.

@novemberborn has rewarded $180.00 to @ulken. See it on IssueHunt

  • :moneybag: Total deposit: $200.00
  • :tada: Repository reward(0%): $0.00
  • :wrench: Service fee(10%): $20.00
Was this page helpful?
0 / 5 - 0 ratings