Skip to content

Audits shouldn't require you to know the URL in order to generate the list of tests #24

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

Closed
glasser opened this issue Nov 18, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request released Has been released and published

Comments

@glasser
Copy link
Collaborator

glasser commented Nov 18, 2022

I would like to integrate the audits in my Jest test suite as shown in the README.

I don’t want to have a fixed port for my URL: I want to be able to listen on port 0 and get the URL back and pass that to the tests.

But I don’t want to actually start and listen on a server at the “top level” of a file, because I don't want it to run unless the particular tests are selected (eg, if it.only or the like disables this part of the test file, I don't want to start a server). So listening should go in beforeAll or beforeEach or something.

But you need to give Jest the list of tests before this code runs, and the API here only gives you the list of audit tests once you already have an URL.

It would work better if the url was an argument to fn instead, or if you can pass a function returning an URL or something.

@glasser
Copy link
Collaborator Author

glasser commented Nov 18, 2022

As a hacky workaround I guess you can actually mutate the opts object after calling serverAudits!

@enisdenjo enisdenjo self-assigned this Nov 21, 2022
enisdenjo pushed a commit that referenced this issue Nov 21, 2022
# [1.8.0](v1.7.2...v1.8.0) (2022-11-21)

### Features

* **audits/server:** Support functions for the `url` option ([f4d20a9](f4d20a9)), closes [#24](#24)
@enisdenjo
Copy link
Member

🎉 This issue has been resolved in version 1.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@enisdenjo enisdenjo added the released Has been released and published label Nov 21, 2022
glasser pushed a commit to apollographql/apollo-server that referenced this issue Nov 21, 2022
glasser pushed a commit to apollographql/apollo-server that referenced this issue Nov 21, 2022
@enisdenjo enisdenjo added the enhancement New feature or request label Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released Has been released and published
Projects
None yet
Development

No branches or pull requests

2 participants