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

refactor tests to be more reliable, use unit tests #281

Open
fago opened this issue Dec 23, 2024 · 4 comments
Open

refactor tests to be more reliable, use unit tests #281

fago opened this issue Dec 23, 2024 · 4 comments

Comments

@fago
Copy link
Contributor

fago commented Dec 23, 2024

Tests hard-code some weird port numbers to access itself, this should not be necessary given the documented helpers.

We should refactor things a bit to

@fago fago changed the title refactor tests to be more reliable refactor tests to be more reliable, use unit tests Dec 23, 2024
@fago
Copy link
Contributor Author

fago commented Dec 23, 2024

it seems like existing tests use some sort of E2E testing with a mocked backend when they should do unit testing. e.g. tests for addRequestFormat() would be a typical unit test that mocks $fetch and verfies the right URL is fetched. It makes sense to have a few E2E test(s) with mocked backend as an integration test, but the majority of tests for all the detailed cases should be tested with unit tests where possible.

#280 lays the foundation for a working unit test caes setup based upon docs.

Once we have that it would make sense to add unit test coverage for our vue skeleton components, such that the right data input gives the right output. We can do that by defining a test component that defines the data and renders it with renderCustomElements helper + use nuxt test-utils to render the component and verify output is correct.

@fago
Copy link
Contributor Author

fago commented Dec 24, 2024

#280 has added a first working unit test + necessary setup, so we can start refactoring others based upon this example. everything we can test just by rendering components and verifying the result we should test with a unit test like this

@fago
Copy link
Contributor Author

fago commented Dec 28, 2024

4c5c319#diff-2ee894bf23aa44ff4ce12a3da8af19ab20180474ebf2176dbe5f2eea3f96dc92 added the config such that we can unit-test with nuxt environment that has the module installed, with that we can finally unit test components.

@fago
Copy link
Contributor Author

fago commented Dec 28, 2024

added more unit tests in #285 - given the existing pattern this is now easy for further components. I think we can now start overhauling existing tests to apply to this pattern and where not move them into a e2e folder to make clear that those tess are using a regular nuxt instance.

fago added a commit that referenced this issue Dec 30, 2024
…nit tests (#286)

* refactor: #281: convert component default handling test coverage to unit tests

* remove old ones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant