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

Expose config object #1984

Closed
RedHatter opened this issue Nov 18, 2018 · 11 comments · Fixed by #2444
Closed

Expose config object #1984

RedHatter opened this issue Nov 18, 2018 · 11 comments · Fixed by #2444
Labels

Comments

@RedHatter
Copy link

RedHatter commented Nov 18, 2018

Issuehunt badges

It would be useful for ava to expose the config object to the tests. For example I need to save some extra files with snapshots, it would be nice if I could pull the snapshotDir from the config.


IssueHunt Summary

ulken ulken has been rewarded.

Backers (Total: $40.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

@RedHatter
Copy link
Author

My bad. You can get the config like so.

import { get as getConfig } from 'ava/lib/worker/options.js';

test('...', (t, page) => {
  getConfig();
  ...
});

@novemberborn
Copy link
Member

You could… but that's an internal API and may break without warning.

Could you elaborate on your use case?

@RedHatter
Copy link
Author

RedHatter commented Nov 25, 2018

I'm building some until functions to create visual snapshots for regression testing using puppeteer. I need access to the config object so I can get the snapshotDir and whether ava was run with --update-snapshots

@RedHatter RedHatter reopened this Nov 25, 2018
@novemberborn
Copy link
Member

#1977 introduces a meta object we could hang this off. We should implement a memoizing getter for snapshotDir since it's takes a bunch of disk operations to compute.

I'm not sure what to do about the update flag. I can see the value in exposing it but I'm concerned it may prevent us from building interactive update UIs later. Though perhaps at that point we won't expose it if run interactively.

There's other open issues to stop AVA from creating new snapshots in CI that may impact this. What do you think?

@RedHatter
Copy link
Author

RedHatter commented Nov 26, 2018

Exposing on the meta options seems perfect.

You could expose the raw command line arguments that were passed to ava. That way if you remove the --update-snapshots option from the snapshot work flow any test or functions that depend on it would still work. In addition it would have the added benefit of allowing me to specify --update-visual-snapshots if I want.

@novemberborn
Copy link
Member

You could expose the raw command line arguments that were passed to ava.

AVA actually forwards all arguments after a --. So if you do npx ava my.test.js -- --update-visual-snapshots you could use that to control some custom snapshotting module.

@RedHatter
Copy link
Author

Ah, okay, was not aware of that.

@sindresorhus
Copy link
Member

I think it should be named meta.snapshotDirectory.

@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label May 10, 2019
@IssueHuntBot
Copy link

@IssueHunt has funded $40.00 to this issue.


@ulken
Copy link
Contributor

ulken commented Apr 7, 2020

I took a stab at this in #2444

novemberborn added a commit that referenced this issue Apr 10, 2020
Fixes #1984.

Co-authored-by: Mark Wubben <mark@novemberborn.net>
@issuehunt-oss
Copy link

issuehunt-oss bot commented Apr 10, 2020

@sindresorhus has rewarded $36.00 to @ulken. See it on IssueHunt

  • 💰 Total deposit: $40.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $4.00

@issuehunt-oss issuehunt-oss bot added 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt and removed 💵 Funded on Issuehunt This issue has been funded on Issuehunt labels Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants