-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expose options object to tests #1057
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
Comments
Perhaps you could pass this path as an environment variable to your tests:
and in your tests: const base = process.env.TESTS_BASE; |
I could - but that still feels like an unpleasant workaround, and it's probably even more obscure than the one I suggested: it's not immediately obvious (in JavaScript) where that value actually comes from. Is there any reason the options object shouldn't be exposed? |
Actually, this solution is straightforward and clear.
We try not to add alternatives/aliases or functionality, that already exists in some other form. If we would, AVA could quickly become hard to maintain. That's why we are so picky what goes in the core and what does not. Each change has to be supported in future versions, so we try to avoid mistakes. Hope you understand ;) Let me know if the |
@sindresorhus - great, using process.cwd() would be ideal. I'll close this one since #32 is covering my use case. |
There may be a way of doing this that I haven't been able to find in the documentation or dicussions of other issues, but I think it'd be nice to be able to access the options object that's used by
Api
.Specifically, I'd like to get at the
resolveTestsFrom
property.Here's an example of why. NB, this is TypeScript, and I'm using
"outDir": "js"
in tsconfig.json.The problem is that ugly
../../
at the beginning of my glob. The number of../
s I have there is coupled to what I set my output directory to in tsconfig.json. In the case of my real project, I end up having to use../../../
to find what I'm looking for because of my directory structure.My current workaround is to do this:
in
_ava-meta.ts
:int
thingTest.ts
:But it's brittle and a bit of a hack.
My suggestion would be to just expose the options object so I can do:
Or is there an already-existing nicer way I can get this value?
The text was updated successfully, but these errors were encountered: