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

pattern CLI option Path Expansion #3206

Open
shellscape opened this issue Jun 5, 2023 · 3 comments
Open

pattern CLI option Path Expansion #3206

shellscape opened this issue Jun 5, 2023 · 3 comments

Comments

@shellscape
Copy link

Please provide details about:

  • What you're trying to do
pnpm exec ava ~/code/tests

This results in an error: Expected pattern to be a non-empty string

The error is both incorrect and unfortunate. The pattern passed was not empty, ava just didn't know what to do with it.

  • Why you can't use AVA for this

Oodles of tertiary tooling will provide paths with a leading tilde. However correct or incorrect that is, it would be useful for local tooling to be able to leverage a tilde as a home directory path.

  • And maybe how you think AVA could handle this

Execute a resolve on the passed pattern if it doesn't match any of the other expected shapes, or begins with a tilde.

→ node
Welcome to Node.js v18.15.0.
Type ".help" for more information.
> const { resolve } = require('path')
undefined
> resolve('~')
'/Users/user/code/test/~'
@shellscape
Copy link
Author

Related to this:

  • absolute paths don't work (and this isn't documented) e.g. /Users/user/code/test
  • local path relative directory specifier doesn't work (and this isn't documented) e.g. ./

@novemberborn
Copy link
Member

Do you have a stack trace for that error?

The pattern is resolved against to the current working directory and then made relative against the project directory:

ava/lib/cli.js

Line 419 in 6398772

pattern: normalizePattern(path.relative(projectDir, path.resolve(process.cwd(), pattern))),

However it doesn't look like that expands the ~.

I'd expect absolute paths to be resolved, however (as I recall) AVA cannot run test files outside of the project directory. Perhaps that could be communicated better.

Local paths really should work.

@shellscape
Copy link
Author

I'll be doing some additional testing today for a related moon issue and will grab a stack trace then.

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

No branches or pull requests

2 participants