Skip to content
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

--grep #74

Open
Rich-Harris opened this issue Nov 27, 2020 · 4 comments
Open

--grep #74

Rich-Harris opened this issue Nov 27, 2020 · 4 comments

Comments

@Rich-Harris
Copy link

I find this flag in mocha to be incredibly useful:

npm test -- -g "some test description"

What do you think about having something similar in uvu?

@lukeed
Copy link
Owner

lukeed commented Nov 30, 2020

hey, does this really add something that suite.only and/or node path/to/test.js doesnt satisfy? IIRC you can't single out a mocha test file directly like you can with uvu, which may be the reason for the flag?

@Rich-Harris
Copy link
Author

node path/to/test.js isn't granular enough. suite.only is close, but less convenient — you have to find the failing test in your codebase and modify the source code, and remember not to accidentally check test.only in (which I have done more times than I can count). Definitely falls under 'nice to have' rather than 'essential', but it is nice to have

@jugglingcats
Copy link

I agree with @Rich-Harris, and in fact just lost some time because I assumed suite.only would allow me to specify the test to run (I didn't realise you have to modify the test case itself with .only). I feel stupid now but think possibly an easy mistake to make for people new to uvu. This is what I wrote:

import * as all_suites from "./src/all_tests"
import { Command } from "commander"

const program = new Command()
program.option("-s, --suite <suite>", "suite to run").option("-t, --test <test>", "test to run <test>")
program.parse(process.argv)

const { suite, test } = program.opts()

for (const [name, runner] of Object.entries(all_suites)) {
    if (!suite || suite === name) {
        if (test) {
            runner.only(test, ctx => {
                console.log("CTX", ctx)
                return Promise.resolve()
            })
        }
        runner.run()
    }
}

Obviously the above makes no sense, but hopefully you can see what I was trying to achieve! Perhaps an optional filter predicate passed to the run method would work?

Thanks

@jugglingcats
Copy link

Having written all the above, adding .only is not a big deal for me...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants