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

Actually run the tests in python 3.12 and 3.13 and remove snapshottest dependency #1572

Merged
merged 5 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions docs/testing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,43 +69,3 @@ You can also add extra keyword arguments to the ``execute`` method, such as
'hey': 'hello Peter!'
}
}


Snapshot testing
~~~~~~~~~~~~~~~~

As our APIs evolve, we need to know when our changes introduce any breaking changes that might break
some of the clients of our GraphQL app.

However, writing tests and replicating the same response we expect from our GraphQL application can be a
tedious and repetitive task, and sometimes it's easier to skip this process.

Because of that, we recommend the usage of `SnapshotTest <https://github.com/syrusakbary/snapshottest/>`_.

SnapshotTest lets us write all these tests in a breeze, as it automatically creates the ``snapshots`` for us
the first time the test are executed.


Here is a simple example on how our tests will look if we use ``pytest``:

.. code:: python

def test_hey(snapshot):
client = Client(my_schema)
# This will create a snapshot dir and a snapshot file
# the first time the test is executed, with the response
# of the execution.
snapshot.assert_match(client.execute('''{ hey }'''))


If we are using ``unittest``:

.. code:: python

from snapshottest import TestCase

class APITestCase(TestCase):
def test_api_me(self):
"""Testing the API for /me"""
client = Client(my_schema)
self.assertMatchSnapshot(client.execute('''{ hey }'''))
Empty file.
98 changes: 0 additions & 98 deletions examples/starwars/tests/snapshots/snap_test_query.py

This file was deleted.

Loading
Loading