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
Expose test file path within the test process #1976
Comments
Yea, I've had a similar use case, but for loading fixtures after resolving a source map. Not sure about attaching it to the per-test execution context. Maybe it can be available through the |
Yes that seems like a better place for it to be. |
I don't really understand this. You can already get the filepath of the test (or any other file being run in Node) using Soon you will be able to use |
@sholladay |
I see. I think I didn't catch onto that because you would also have to pass Wouldn't |
AVA loads the test file, so it can set that up in advance. |
@sholladay I've submitted a patch for the functionality in #1977, was pretty straight forward. |
This adds `test.meta.file` which exposes the filename of the test being run by AVA. Fixes #1976
@novemberborn could you reopen this? I'm experimenting with some potentially advanced features of nyc. Specifically if we run if (currentTest === 'test/feature1.js') {
nycConfig.include = ['lib/feature1.js']; // only instrument the current test target
} Unfortunately these |
@coreyfarrell I think you're running into something else. #2035 changed how the test file is passed to the worker process, so it's no longer available through We'll also, at some point, support different styles of workers, see #2011. Of course it'd be fine if not all of those modes can be hooked into by nyc, that just means AVA should incorporate nyc directly. The previous discussions have all focused on how this is exposed through AVA itself. I think for your use case we need something outside of AVA. Perhaps an environment variable: |
So you're suggesting that ava would set I'm a little unclear from #2011, looks like this will require that we disable one/more options to get the current process per test behavior? |
Precisely.
We'll see where we settle on as far as the default behavior is concerned, but I can see how certain modes may not work with your use case. But then again they also won't work if you modify globals, so it'll be really project specific. |
Description
I need the ability to save test artifacts similar to how
t.snapshot
creates.md
and.snap
files. This requires knowing the filename of the actual test file being executed to be available - I assume viat
but I'm open to any suggestions. I tried finding what I needed thoughprocess
butprocess.argv[2]
is undefined. Even if the test filename were available fromprocess
I think it would be better to get it fromt
.Test Source
First I tried using
t.snapshot
on image captures from the browser:https://github.com/cfware/rollup-webapp/blob/be9505c214bc2efead7e1467c322bc587bd46aa1/test/helpers/selenium.js#L49-L55
https://github.com/cfware/rollup-webapp/blob/be9505c214bc2efead7e1467c322bc587bd46aa1/test/helpers/selenium.js#L86-L92
https://github.com/cfware/rollup-webapp/blob/be9505c214bc2efead7e1467c322bc587bd46aa1/test/helpers/pages.js#L4-L10
Unfortunately different test environments cause the browser to render fonts differently so Travis-CI cannot match snapshot PNG's generated in my local testing.
My new plan is to create a function
t.context.saveImage(ele, imageID)
to create files such astest/captures/firefox.js-app.html-imageID.png
so they can be manually reviewed. Sorry I don't have a simple example but iftest/firefox.js
were to create artifacts directly I would be able to just use__filename
.Environment
The text was updated successfully, but these errors were encountered: