This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- We don't want to populate resolvers over and over again for each test file, so we will use a frozen prepopulated database. (the other non-resolver tests mutate the database).
- remove unused scripts - change script name from migrate-all to migrate - Include migration of tests in test migrate script - Update command to run resolver tests
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is better to have two separate test environments (two test databases),
one for testing resolvers (which is closer to an integration test), and the other for testing everything else.
When testing graphql resolvers, seeding the database should only be done once as this is a slow operation.
Currently, using
globalSetup
andglobalTeardown
with jest doesn't work for setting up thetypeorm
database.The tests are not able to find the connection.
See:
#73
typeorm/typeorm#5308
jestjs/jest#10178
It is also not efficient to remove all of the entries for this database in order to start with a clean slate for
testing the models and testing the seeding operations. So what we do here is we have two test databases.
test_db
) to be used by the graphql resolversempty_test_db
) which we can safely mutate (like inserting and deleting operation) to test seeding functions, among othersSo this pull request updates all the scripts and other files for the current tests to work
I have also refactored some of the test scripts to be more readable and also added
a simple test for testing the
abilityById
graphql query..