lighthouse icon indicating copy to clipboard operation
lighthouse copied to clipboard

Support SQLite during tests

Open jaulz opened this issue 1 year ago • 2 comments

  • [ ] Added or updated tests
  • [ ] Documented user facing changes
  • [ ] Updated CHANGELOG.md

Changes

This PR allows developers to easily use SQLite during testing without setting up a MySQL database.

Breaking changes

n/a

jaulz avatar Apr 09 '24 07:04 jaulz

What are the steps to actually use SQLite testing? Do all tests pass with it?

spawnia avatar Apr 21 '24 15:04 spawnia

It's quite easy:

  • Create local database sqlite test (make sure you select anything, e.g. SELECT 1;, so it creates the file)
  • Add environment variable in phpunit.xml:
    <env name="LIGHTHOUSE_TEST_DB_DRIVER" value="sqlite"/>

Unfortunately, not all tests pass but they help me to develop in an environment (gitpod.io) to quickly iterate on ideas. These tests fail:

There were 3 failures:

1) Tests\Integration\Cache\CacheDirectiveTest::testCacheHasManyResolver
This query should only run once and be cached on the second run.
Failed asserting that 0 is identical to 1.

/workspace/lighthouse/tests/Integration/Cache/CacheDirectiveTest.php:397

2) Tests\Integration\Cache\CacheDirectiveTest::testAttachTagsToCache
This query should only run once and be cached on the second run.
Failed asserting that 0 is identical to 1.

/workspace/lighthouse/tests/Integration/Cache/CacheDirectiveTest.php:467

3) Tests\Integration\Schema\Directives\LikeDirectiveTest::testLikeClientWildcardsAreEscapedFromTemplate
Unable to find JSON fragment: 

[{"users":[{"name":"Aar%on"}]}]

within

[{"data":{"users":[]}}].
Failed asserting that false is true.

/workspace/lighthouse/vendor/laravel/framework/src/Illuminate/Testing/AssertableJsonString.php:142
/workspace/lighthouse/vendor/laravel/framework/src/Illuminate/Testing/TestResponse.php:761
/workspace/lighthouse/tests/Integration/Schema/Directives/LikeDirectiveTest.php:108

jaulz avatar Apr 21 '24 18:04 jaulz